In this article, we learn how to install and initially configure MySql 8.0 Server on Ubuntu 18.04 LTS Server.
Mysql is one of the most used and famous Relational Database Server available on the internet because It is very reliable and secure and also it’s easy to learn and operate it. MySql uses SQL “Structured Query Language” for performing operations.
- How to Install Latest PHP 7.3 on Ubuntu 18.04
- Creating a backup user with read-only permission for MySQL DB
We will learn it in some simple steps. So let’s start with the first step.
Step 1: Download MySql 8 Package
At the very first step, we have to Download the MySql repository using the wget command :
- For more options see: https://dev.mysql.com/downloads/mysql/
Step 2: Configure MySql 8 Package
After that, install the repository package using below command:
dpkg -i mysql-apt-config_0.8.13-1_all.deb
Select OK when asked for choosing MySql product to configure but By default, the latest version 8 is selected like the below image.
Step 3: Install MySql 8 Package
After this, use the below command for begun the installation of MySql Community Server 8.
sudo apt-get update sudo apt-get install mysql-server
Note: Run below commands only if you get an error like this – “mysql-server : Depends: mysql-community-server (= 8.0.12-1ubuntu18.04) but it is not going to be installed”
sudo add-apt-repository universe sudo apt update sudo apt install libmecab2
Step 3.1: Set MySql root password
In the first step, you need to set up the root user password for MySql Server because the “root” is the default user for the MySql server.
Step 3.2: Choose MySql authentication method
In this step, you have to choose the default authentication plugin for MySQL.
Remember: if you choose the first option “Strong Password Encryption” then the Old Authentication method will not work and your old Web Application did not work if you do not update them according to MySql 8 because the SQL Query for password authentication is changed.
That’s why if you want to run a previously developed web application with MySql 8, I suggest the Second option “Legacy Authentication Method”. You can see the options in the below image:
Step 3.3: Confirm MySql installation
After that, confirm that the MySQL server is successfully installed in our system with running the below command:
sudo dpkg -l | grep "mysql-community"
Now, you should see the following output:
Step 3.4: Secure MySql installation
By default, MySQL installation is a little insecure and therefore we need to secure it.
After that, you will be asked to choose some options. At first step, you will be asked for MySQL root password which one you create during MySQL installation.
In the next step, you will be asked to choose whether to enable the “Validate Password” plugin or not because this plugin is used for checking MySql user password for a standard format to increase the security.
After that, you have to choose yes or no for some security questions but I recommend that you should choose the below-given answers:
- Remove anonymous users? (Press y)
- Disallow root login remotely? (Press y)
- Remove test database and access to it? (Press y)
- Reload privilege tables now? (Press y)
After that, you should get the below screen:
Step 3.5: Start and Enable MySql service
After that let’s enable the MySQL server for boot time and start the server by below commands:
sudo systemctl start mysql sudo systemctl enable mysql sudo systemctl status mysql
After that, you should get the below status:
Now we have successfully installed and running MySql database server.
Step 3.6: Get access to MySql Server
After that, you can try to login in with the below commands:
sudo mysql -uroot -pMypassword
- If you don’t like to work on CLI mode you can Install PhpMyadmin for MySql GUI.
So in this tutorial, we successfully learn how to install and securing MySql 8 Database Server but if you feel that something is missing or hard to understatnd, please mention that in the comment section. Also, you can suggest topics for the next article.