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. In this article, we will describe the installation procedure of MySQL on Ubuntu 20.04 LTS. Once we will complete the installation of this application then, we will launch or host it through the terminal.
It is necessary that you must have sudo command privileges or must login as a root user on your system.
Installation Steps of MySQL on Ubuntu 20.04
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:
Step 1: Update apt repository
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
Step 2: Install MySQL server
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.
Step 3: Verify the 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
From the above-displayed screenshot, you can observe that all MySQL services are running on this system.
Step 4: Make secure the MySQL configurations
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
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:
- Remove anonymous users?
- Disallow root login remotely?
- Remove the test database and access to it?
- Reload privilege tables now?
You will enter ‘y’ in order to confirm the all above statements.
Step 5: Host MySQL Server
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
Basic commands to run MySQL Server
In this section, 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 personal_db;
In the above-mentioned command, we have created a new database named ‘personal_db’.
You can also create new user MySQL account by writing the following command:
mysql> CREATE USER ‘karim’@’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:
We have elaborated on how to install and configure MySQL server on the Linux system Ubuntu 20.04 in this article. Moreover, we have explored different basic commands to run MySQL server. I hope you really enjoyed this article.