MySQL is an open-source relational database management system under the terms of the GNU General Public License. Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language. In this tutorial, you will learn how to install MySQL on ubuntu 20.04
Install MySQL on Ubuntu
sudo apt update
sudo apt install mysql-server
2. Check MySQL Version
3. Secure MySQL and set the password
VALIDATE PASSWORD COMPONENT 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
This will take you through a series of prompts where you can set your MySQL installation’s security options. The first prompt will ask you Would you like to setup VALIDATE PASSWORD component? Press Y and hit Enter to set password.
Second prompt will ask you levels of password validation policy. There are Three levels of Policy:
Level 1: numeric, mixed case, and special characters
Level 2: numeric, mixed case, special characters and dictionary file
You can choose from 0,1,2 as your requirement. 0 is for least secure and 2 is for most secure. Here I am entering 0.
The third and Fourth prompts will ask you for New Password and Re-enter new password. Enter password as per level rule.
Now you have set a password for the root MySQL user.
Now, It will ask you a series of questions, Answer as per your customisation.
Remove anonymous users?
Disallow root login remotely?
Remove test database and access to it?
Reload privilege tables now?
Check MySQL Status
sudo systemctl status mysql
Login to MySQL
Login as root
On MySQL 8.0, the root user is authenticated by the
auth_socket plugin by default. So, you can login to MySQL without password. Just use sudo mysql command in terminal.
You can also login using sudo mysql -u root -p command in terminal. Here you need to enter the password. This method is valid for all MySQL versions.
sudo mysql -u root -p
For root (sudo) User
mysql -u root -p
|Install MySQL on Ubuntu 22.04|
|Install MySQL on Ubuntu 20.04|
|Permanently Remove, Uninstall MySQL from Ubuntu|
|Fix MySQL root password setup error in ubuntu|
|Reset or Change the MySQL root Password on Ubuntu|