Deprecated: Function is_staging_site is deprecated since version 3.3.0! Use in_safe_mode instead. in /var/www/ on line 6078
How to: Install MySQL in an Ubuntu Server – Knowledge eXchange
Deprecated: Function is_staging_site is deprecated since version 3.3.0! Use in_safe_mode instead. in /var/www/ on line 6078

How to: Install MySQL in an Ubuntu Server

How to: Install MySQL in an Ubuntu Server

If you are looking into deploying MySQL as part of a “LAMP” installation or whatever flavors you like best, Ubuntu is a good OS to do so. I say that because they make the installation super easy from the command line with apt-get, it doesn’t get much simpler than that.

I recommend installing MySQL the following way:

  1. Get the latest updates before you install
    • sudo apt-get update
  2. Run apt-get to install MySQL
    • sudo apt-get install mysql-server
  3. Type your root password for MySQL. Don’t forget to write it down or whatever you need to do
  4. You’re done!

If you wanted to verify the network bindings that MySQL has in place you can execute the following command:

sudo netstat -tap | grep mysql

which in return will show something similar to this:

tcp 0 0 localhost:mysql : LISTEN 3040/mysqld

If you encounter any issues remember mysql runs as a service so you can stop, start or restart if you want using the following command:

sudo service mysql stop|start|restart

There are more than a few settings you can specify in the configuration file for MySQL. Remember that every time you make a change you are going to have to restart the service.


You can edit the /etc/mysql/my.cnf file to configure the basic settings — log file, port number, etc. For example, to configure MySQL to listen for connections from network hosts, change the bind-address directive to the server’s IP address:

bind-address            =

Replace with the appropriate address.

After making a change to /etc/mysql/my.cnf the MySQL daemon will need to be restarted:

sudo service mysql restart

If you would like to change the MySQL root password, in a terminal enter:

sudo dpkg-reconfigure mysql-server-5.5

The MySQL daemon will be stopped, and you will be prompted to enter a new password.


Percona Server

Percona Server 5.6 is the latest release of our enhanced, drop-in replacement for MySQL®. The new version offers all the improvements found in MySQL 5.6 Community Edition plus scalability, availability, backup, and security features found only in MySQL 5.6 Enterprise Edition, which requires a support contract from Oracle to access. The free download of Percona Server 5.6 also includes superior diagnostics and improved integration with other Percona software.

I have been doing some research into how to fine tune my database server as the response rate I was getting was slow enough to be noticed across the board. There are tools like mysqltuner which I’ll cover later on but after much reading I came across Percona Server. As you can read from the introduction of their 5.6 version it is based on MySQL but with additions that make it perform better. I am recommending now installing Percona Server over MySQL in order to get the added benefits. It is a drop in replacement, which means your clients can use Percona server with out knowing it is not their vanilla MySQL server.

In order to install Percona server, do it on a clean server that doesn’t make MySQL already installed (or remove MySQL but don’t forget to backup your db). Below are the simple instructions to install Percona Server:

I. Add the Repo

apt-key adv --keyserver --recv-keys 1C4CBDCDCD2EFD2A

echo "deb lsb_release -cs main" >> /etc/apt/sources.list.d/percona.list

echo "deb-src lsb_release -cs main" >> /etc/apt/sources.list.d/percona.list

apt-get update

Note: ‘lsb_release -cs’ will automatically place your current version on your sources.list.d file. If for some reason you get 404 errors like the ones below, it probably means that didn’t work for whatever reason. Simply put in your version instead and you’re done!

Err lsb_release/-cs Sources
404 Not Found
Hit saucy-backports/universe i386 Packages
Err lsb_release/main Sources
404 Not Found
Get:10 saucy-security/multiverse amd64 Packages [1,160 B]
Hit saucy-backports/multiverse i386 Packages
Err lsb_release/-cs amd64 Packages
404 Not Found
Hit saucy-backports/main Translation-en
Err lsb_release/main amd64 Packages
404 Not Found
Get:11 saucy-security/main i386 Packages [104 kB]
Hit saucy-backports/multiverse Translation-en
Err lsb_release/-cs i386 Packages
404 Not Found
Err lsb_release/main i386 Packages
404 Not Found


W: Failed to fetch 404 Not Found

W: Failed to fetch 404 Not Found

W: Failed to fetch 404 Not Found

W: Failed to fetch 404 Not Found

W: Failed to fetch 404 Not Found

W: Failed to fetch 404 Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.


deb VERSION main
deb-src VERSION main

Example for Ubuntu 13.10 Saucy Salamander:

deb saucy main
deb-src saucy main

II. Install the Server

apt-get install percona-server-server-5.6

III. (Optional) Install the Client

apt-get install percona-server-client-5.6

IV. Reset the root password in case you forget it (you will need the client installed)

mysqladmin -u root password MYNEWPASSWORD

Enjoy a faster MySQL experience!


Enhanced by Zemanta

You may also like...

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.