In this tutorial, AZDIGI will show you how to install MySQL on Ubuntu 20.04.
MySQL is an open-source database management system, usually installed as part of systems using the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl). It implements the relational model and uses Structured Query Language (also known as SQL for short) to manage its data.
This tutorial AZDIGI will describe how to install the
MySQL 8.0 version on the
Ubuntu 20.04 server. Once the installation is complete, you will have a working database that you can use to serve your other websites or applications.
Prerequisites: A server running Ubuntu 20.04 with an administrative user as
root or a user with
sudo privileges and a firewall configured with
II. Install MySQL on Ubuntu 20.04
To install MySQL on Ubuntu 20.04, we need to do the following 3 steps.
Step 1: SSH into your Ubuntu 20.04 system
To install MySQL on Ubuntu 20.04, we first need to SSH or access your VPS/server as root or a user with
sudo privileges. If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:
After successfully SSH as root, we continue with step 2 to perform the MySQL installation commands on Ubuntu 20.04.
Step 2: Execute the command Install MySQL on Ubuntu 20.04
On Ubuntu 20.04, you can install MySQL using the
APT package repository. At the time of this writing, the version of MySQL available in the Ubuntu repositories defaults to version
To install MySQL, we’ll need to update the package index on your server in case you haven’t done so recently:
sudo apt update
After the update is complete, we proceed to install the
mysql-server package with the following command:
sudo apt install mysql-server
When asked, select
Y to allow the installation to continue.
This will install MySQL but won’t ask you to set a password or make any other configuration changes. So this will make your MySQL installation unsafe because the configuration is only at the default level, we will deal with this in the next steps.
After the installation is complete, use the
mysqld -V command to check the installed version of MySQL.
Step 3: Initial MySQL Configuration
For new installations of MySQL, you will need to run the included security script of the DBMS (Database Management System). This script will help change less secure default options for credentials, remote permissions, anonymous users, and database tests.
You need to run the following command:
This will take you through a series of questions where you can make configuration changes to security options after installing MySQL.
The first question is whether you want to set up password authentication or not, you can also set the difficulty level of the password. After you set the password, the system will also check the password strength you have set for new MySQL users before deeming them valid or not.
If you choose to set up requiring authentication passwords, any MySQL users you create will need to authenticate with a password and be required to have a password that meets the policy you choose. To claim the strongest password policy – which you can choose by entering
2 – will require the password to be at least eight characters long and consist of a mixture of uppercase, lowercase, numeric and special characters.
Whether you choose to set up an authentication password or not, the next question will be to set a password for the MySQL root user. Enter the password and then confirm the password again.
And the next question is, do you want to remove anonymous users? You should delete these users.
In the next 3 options, you will be asked for the following information:
- Do you want to disable remote access with the
rootuser? This depends on your needs. If you want security, you should choose
- Do you want to delete the test database? Usually, you should choose
Yesbecause it has almost no practical application.
- Is there a requirement to reload privileges? The default is
Yesin almost all cases.
After the configuration is complete, you can completely access the MySQL administration with the
mysql -u root -p command and enter the MySQL root password that you configured earlier.
mysql -u root -p
root, you have full rights to be able to create users, databases and many other operations you want.
At this point, our installation of MySQL on Ubuntu 20.04 is complete.
As you can see, installing MySQL on Ubuntu 20.04 is relatively easy. In the next article, AZDIGI will introduce how to use MySQL with the command to help you get acquainted with how to create a database, a user, and how to enable remote access for that user.
If you need assistance, you can contact support in the ways below:
- Hotline 247: 028 730 24768 (Ext 0)
- Ticket/Email: You use the email to register for the service and send it directly to: email@example.com .