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 UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot
Posted by Arne Hartherz to makandra dev (2011-02-22 17:01)