Read more

How to change MySQL's data directory

Arne Hartherz
February 22, 2011Software engineer at makandra GmbH
  1. Have a backup.

  2. Stop MySQL:

    sudo service mysql stop
    
  3. Move (or copy) your mysql directory. If you want /mnt/mysql to be the new directory, do it like this:

    sudo mv /var/lib/mysql /mnt/
    
  4. Open your MySQL configuration (sudo vim /etc/mysql/my.cnf) and change the datadir value to your new path (e.g. /mnt/mysql)

  5. Modify your AppArmor configuration:

    sudo vim /etc/apparmor.d/usr.sbin.mysqld
    

    Change/copy the lines granting access to /var/lib/mysql to your new path. Otherwise MySQL will not start.

  6. Load your new AppArmor configuration:

    sudo service apparmor reload
    
  7. Start MySQL:

    sudo service mysql start
    
Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot
Posted by Arne Hartherz to makandra dev (2011-02-22 17:01)