
MySQL is an open-source and most popular database management system. MySQL installation on Ubuntu is very easy and it’s commonly being a part of the popular LAMP and LEMP stacks. This tutorial will help you to install MySQL on Ubuntu 18.04 Bionic Beaver systems.
Prerequisites
Ubuntu 18.04 server with a non-root user with sudo privileges. To remote a system use SSH in Linux and in Windows you can use Putty application to make SSH connection.
Install MySQL on Ubuntu 18.04
Before start installation you need to update the package index on your system. Execute following command :
sudo apt update
Run the below commands to start installation:
sudo apt install mysql-server
It will ask you to set MySQL root user password. On completion of installation, the MySQL service will start automatically. Also, you can check whether the MySQL server is running, type below command:
sudo systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-03-21 18:22:17 IST; 2min 1s ago
Main PID: 6260 (mysqld)
CGroup: /system.slice/mysql.service
└─6260 /usr/sbin/mysqld
Securing MySQL & Configuring
It’s recommended to run included security script. By this script it will make changes in default options like remote root logins and sample users and test database. Run the following security script:
sudo mysql_secure_installation
Once you execute this command it will prompt you to enter root user password which you set before this step. First of all it will ask you to choose whether to use the VALIDATE PASSWORD plugin or not, which can be used to test the strength of your MySQL password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:
Press Y and hit Enter to go ahead.
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
After that, it will ask you for select a level of password validation. Make sure here if you have select 2 for for the strongest level then it will not allow password without numbers, upper and lowercase letters, and special characters. So here you should select 1 for medium level and hit Enter.
Next, It will ask if you want to change that password. If your current password is perfect then, enter N for “no” at the prompt:
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
Now, for all next questions press Y and hit Enter key for each. This will remove some anonymous users and test database, disable remote root logins and load these new rules so that MySQL immediately respects the changes you have made. Following questions will be prompted and you have to press yes/y for all :
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 login to mysql using following command as root user :
sudo mysql -uroot -p
Enter you mysql root user password and it seems you logged in.
All done. Finally, you successfully installed MySQL on your system.
Leave a Reply