Install and configure MySQL on Ubuntu 14.04

Install MySQL

sudo apt-get -y install mysql-server

Configure MySQL

  • Run the MySQL Secure Installation script.
    sudo mysql_secure_installation
  • Backup the MySQL configuration file.
    sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.orig
  • Edit the MySQL configuration file.
    sudo nano /etc/mysql/my.cnf
    • Set a reasonable query cache size.
      • Replace
        query_cache_size = 16M
      • With
        # Set the size of the query cache to 32M.
        query_cache_size = 32M
        # Set the query cache to always be enabled.
        query_cache_type = 1
    • Set a reasonable buffer pool size.
      • Add
        # Set the InnoDB buffer pool size to 128M.
        innodb_buffer_pool_size = 128M
        # Prevent duplicate caching by the filesystem.
        innodb_flush_method = O_DIRECT
      • After
        # ssl-key=/etc/mysql/server-key.pem
  • Restart the MySQL service.
    sudo service mysql restart
  • Periodically update the mysql configuration file based on the output of the following scripts:

Open Source Software:

Operating System: