You are viewing an old version of this page. View the current version.

    Compare with Current View Page History

    Version 1 Next »

    There are a lot of answers on Google about moving a MySQL datadir, but the gist of it on linux is:

    1. Be logged into the Supervisor as the root user
    2. Stop the Supervisor service: 
      1. /etc/init.d/supervisor stop
    3. Stop the mysql server: 
      1. /etc/init.d/mysqld stop
    4. Copy the current datadir over to the new location ensuring that you preserve ownership and permissions
      1. cp -rP /var/lib/mysql /newpath/mysql
    5. Rename the current datadir so that it won't be found by mistake, but leave it in place so you have a fallback plan: 
      1. mv /varl/lib/mysql /var/lib/mysql.MOVED
    6. Edit the /etc/my.cnf, copy the datadir line, comment out the original as a backup (part 2 of the fallback plan), and edit the uncommented line to point to the new location
    7. Start the mysql server: 
      1. /etc/init.d/mysqld start
    8. Check that the new datadir is the one being used:
      1. mysql -u root -e "SHOW variables like 'datadir'"
    +---------------+-----------------------------------------------+
    | Variable_name | Value                                         |
    +---------------+-----------------------------------------------+
    | datadir       | /usr/local/MySQL-5.1.44-MACOSX-Universal/var/ |
    +---------------+-----------------------------------------------+
    

    If it looks good, start the Supervisor service: 

    /etc/init.d/supervisor start

    • No labels