How to install MySQL on Ubuntu 16.04

Try it in our public cloud & Get $5 Credit

Installing MySQL on Ubuntu 16

MySQL installation on Ubuntu 16 is not very different from previous versions. Actually, the package names are the same and even the MySQL secure installation script is very similar.


To complete this guide, you will need the following:
• 1 Node (Cloud Server or Dedicated Servers) with Ubuntu 16.04 LTS installed


To install MySQL, first set apt-get to query the most up to date list of repositories by running an apt-get update.

apt-get update

We will install 3 packages: mysql-server, libmysqlclient-dev, python-mysqldb. Mysql-server is the main MySQL package, libmysqlclient-dev is the MySQL development library and python-mysqldb is the python interface for MySQL. While the mysql-server package is essential, the others are optional and listed there as they may be useful for most usage. The command is as follow:

apt-get install mysql-server libmysqlclient-dev python-mysqldb

During package installation, you will have a prompt asking you for a new root password. You will need that password when login in to MySQL as the super user.

Once the installation process is finished, you may want to secure your MySQL, especially when used in production. To do that, there is a script called mysql_secure_installation which you can call from the command line, no other utilities necessary.


The script will ask several questions. The root password would not need to be changed. However, it is recommended to remove anonymous users, disallow remote login if you are not going to query the server remotely, remove the test database and reload the privilege on tables.

Once that’s finished, you can now login to mysql in command line. To do so, use the following command:

mysql -u root -p

Enter your password and you will now be logged into the MySQL command line client.


Your MySQL is now ready for production use. Go revolutionize the world!
If you enjoyed this article, please share, comment and let us know what other subjects you would like us to tackle next.