Are you trying to install MySQL on Ubuntu?
This guide is for you.
MySQL server is an open-source relational database management system. SQL stands for ‘Structured Query Language’. It can be used for various domains data warehousing, e-commerce applications, and logging.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform MySQL installation on Linux.
In this context, we shall look into the steps to install MySQL on Ubuntu 20.04 LTS.
Before proceeding with this installation, it is important to have sudo command privileges or must login as a root user on your system.
You need to install the required MySQL server packages to host the MySQL database on your Ubuntu 20.04 system. MySQL is available for installation in the Ubuntu Apt repository. So, you can get the latest package of MySQL server easily from the Ubuntu repository. We have executed all commands on the terminal.
However, you need to open the terminal on your system. Click on Activities and then from the application search bar you can launch it.
You need to implement the following steps to install the latest MySQL package on your Ubuntu system.
It is recommended to update the Ubuntu apt repository on your server before installing any new required package. Therefore, by using the following command you can update the apt repository:
$ sudo apt update
Once the apt repository is updated, you will install the MySQL server package on your system. To do this, execute the following command on the terminal:
$ sudo apt install mysql-server
The above-given command will install the MySQL server on your system. But, it is recommended to make secure the MySQL server installation.
After completing the installation of MySQL server, its services will automatically start on your system. To view the status of the running services of MySQL server, you can execute the following command:
$ sudo systemctl status mysql
This will ensure that all MySQL services are running on this system.
To make the installation secure, you need to run the security script to make the secure configurations of MySQL server. When you will run the script on your terminal, it will ask to change less secure features such as remote logins for root users. Type the following command to make the configurations more secure:
$ sudo mysql_secure_installation
Here, Press 'y' key from your keyboard to allow the installation of 'Validate password plugin'. This plugin will install and then configure on your system. This is used to test the password strength for MySQL users. It also improves the security level as well.
Three different levels of password validation policy you will see that are low, medium, and strong. You need to select a strong password for MySQL server. Therefore. Choose option '2' for strong password strength. In the next step, it will ask you to enter the password of MySQL for the root user account.
If the 'validate password plugin' is already set up then, it will only display the new password strength. You will press 'y' for new password confirmation.
In the next step, it will ask you to confirm the following questions:
a. Remove anonymous users?
b. Disallow root login remotely?
c. Remove the test database and access to it?
d. Reload privilege tables now?
You will enter 'y' in order to confirm the all above statements.
To interact with MySQL server, you need MySQL client utility which is installed on your system during the installation of MySQL server. Now, you can run the MySQL server through the terminal. You can access the command line view of MySQL by running the following command:
$ sudo mysql
Here, we will discuss some basic SQL commands that will help you when you will work on it. You can create your new own database by executing the following command:
mysql> CREATE DATABASE new_db;
This command is to create a new database named 'new_db'.
You can also create new user MySQL account by writing the following command:
mysql> CREATE USER 'root'@'localhost' IDENTIFIED BY 'password';
You can run flush privileges command that will reload the grant tables and make changes in the database:
mysql> FLUSH PRIVILEGES;
You can exit from the MySql command shell by running the following command:
mysql> exit