Install, Configure & Optimise MySQL on Debian

Step 1 : Adding the Dotdeb repository

You can skip this step if you have already added the Dotdeb repository while installing NGINX and PHP-FPM on your Debian Squeeze Server. We need to grab the latest version of MySQL to benefit from all new updates and bug fixes. Read this article for information on adding the Dotdeb repository to your Rackspace Cloud Server.

Step 2 : Install the MySQL server and client

Installation is simple. Just use the following command.

[shell]apt-get install mysql-server mysql-client[/shell]

You will be prompted to key in the MySQL ‘root’ password during the installation. Make sure the password is hard to crack. Once the install is over, you can run


to remove the ‘test’ database and test users. MySQL should be up and running by now!

Step 3 : Configuring and optimising the MySQL Server

MySQL can get resource hungry. There are many articles around the web that talk about MySQL optimisation. The few settings that I have shown here will help free up some memory (RAM). Edit the following MySQL configuration file.


The settings that are already in the MySQL configuration file are pretty decent. You can add just the following to free up some additional memory.

key_buffer = 8M

You can use the Perl script found at to further optimise the database server.

Step 4 : Creating a new database user and database

We will need to create a new database and user for the WordPress installation. The following command should do that.
[shell]mysql -h localhost -u root -pPassword[/shell]
GRANT USAGE ON *.* TO ‘newuser’@’localhost’ IDENTIFIED BY ‘password’
GRANT ALL PRIVILEGES ON `newdbname`.* TO ‘newuser’@’localhost’

This command will create a newuser with a password and assign the user to the new database with the name newdbname.

Step 5 : Restart the MySQL server

[shell]service mysql restart[/shell]

That’s it! You now have a working MySQL database server.


2 responses to “Install, Configure & Optimise MySQL on Debian”

  1. Rieks Visser

    Nice simple tutorial. In recent mysql versions (5.1+) there’s some changes in configuration:

    – skip-innodb should be two rules:

    – skip-locking is enabled by default. It’s now called skip-external locking


  2. You should have explained that what you are doing is disabling InnoDB support which is not by any means and optimization if you require innodb. I think the suggestion about changing buffer size once more is debatable, when I read “optimize” I understand “perform better”, not necessarily save some memory.

    I think this article lacks context and although can be an interesting tip can cause more trouble than help.