Installing MySQL on Ubuntu/Debian

MySQL is the most popular open source relational database management system (RDBMS) in the world. MySQL is used by everyone from the simple small business website to the large internet giants like Facebook, Google or Amazon. In fact the contents of this page are even stored within MySQL.

Installing MySQL is a fairly common task for any systems administrator; especially if that administrator is running a standard LAMP stack (Linux, Apache, MySQL & PHP/Python/Perl).

The following steps outline how to install mysql on a Debian/Ubuntu server. These steps are fairly similar for Red Hat based distributions and can be used by simply replacing apt-get with yum.

Installing MySQL with apt-get

During the installation you will be asked to provide a root password. I suggest making this password different than your servers root password especially if you have DBA’s managing the MySQL instance but do not want them to have access to root on the server.

The apt-get command will also install the mysql-client package which is necessary to login to mysql from the server itself.

Verifying MySQL is installed

MySQL will start automatically after the installation, to validate that it is installed and running properly you can do the following steps

If the above commands work than you are able to connect to mysql on localhost and start using it.

Change the listening address for MySQL

By default MySQL will listen on localhost (127.0.0.1) only, if you want to connect to MySQL from another server you will need to change this IP address to whatever IP you want to connect to. To do this simply edit the my.cnf file and change the bind-address attribute

About Benjamin

Benjamin is a Infrastructure and Software Engineer. On this blog he writes about Linux, Docker, Programming as well as other Systems topics.

Learn more about Linux

If you liked this article, check out Benjamin's book: Red Hat Enterprise Linux Troubleshooting Guide. Where you can learn a lot more about troubleshooting Linux systems. This book is filled with tips and techniques he has learned over years of managing mission critical systems.