In this article, we will have explained the necessary steps to install and configure MySQL server on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with
sudo privileges. All the commands in this tutorial should be run as a non-root user.
MySQL MySQL is an open-source database management system, commonly installed as part of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It implements the relational model and uses Structured Query Language (better known as SQL) to manage its data.
- Operating System with Ubuntu 20.04
- Server IPv4 Address with Superuser Privileges (Root Access)
- Gnome Terminal for Linux Desktop
- PuTTy SSH client for Windows or macOS
- Powershell for Windows 10/11
- Familiar with APT Commands
Install MySQL Server on Ubuntu 20.04
Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.
sudo apt update sudo apt upgrade
Step 2. Installing MySQL server on Ubuntu.
Install the MySQL package with the following command:
sudo apt install mysql-server
Once the package installer has finished, we can check to see if the MySQL service is running:
sudo service mysql status
Step 3. Securing MySQL.
You should now run mysql_secure_installation to configure security for your MySQL server:
Then enter yes/y to the following security questions:
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
You can now log into the MySQL server. Because you are running this command as
sudo, this will automatically log into MySQL using the MySQL root account. If you are prompted for a password, enter your Linux root account password, not the MySQL one.
That’s all you need to do to install the MySQL server on Ubuntu 20.04 Focal Fossa. I hope you find this quick tip helpful. Kindly share your valuable suggestions/queries in the below comment box and leave your worthwhile feedback.