how to install mysql in ubuntu 18.04

MySQL is a database management system. It will organize and provide access to databases where our site can store information.
When you install MYSQL server for Ubuntu 18.04 System you need to use this command:-

  • $ sudo apt-get install mysql-server

Press Y for Yes when You get the confirmation message.
After installing MYSQL server you need to secure your installation bcoz at the time of installation it is not secure.
So do this first using this command:-

  • $ sudo mysql_secure_installation

When you use this command your screen will show many questions and it also asked you about the password and the root password also so you set it firstly.

  • 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: Y
  • 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: 2
  • Please set the password for root here.
  • New password:
  • Re-enter new password:
  • Estimated strength of the password: 100
  • Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
  • By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
  • Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
  • Success.
  • Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network.
  • Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
  • Success.


By default, MySQL comes with a database named ‘test’ that anyone can access. This is also intended only for testing and should be removed before moving into a production environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y

  • Dropping test database
  • Removing privileges on test database…

Reloading the privilege tables will ensure that all changes made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

All done!

After installing and secure MYSQL successfully
You need to test your installation so login using this command:-

  • $ sudo mysql -u root –p

All Done Enjoy 🙂

Also Read: How to Install Mariadb

Leave a Reply

Your email address will not be published. Required fields are marked *