[HOW TO] Change MySQL directory /var/lib/mysql to another one?

Refers to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 12.0 for Linux

Created:

2016-11-16 12:54:51 UTC

Modified:

2016-12-21 19:31:21 UTC

0

Was this article helpful?


Have more questions?

Submit a request

[HOW TO] Change MySQL directory /var/lib/mysql to another one?

Question

How to change /var/lib/mysql to another directory?

Answer

  1. Create a backup of /etc/my.cnf :

    cp /etc/my.cnf{,_backup}
  2. Copy all files from /var/lib/mysql to desired directory:

    # cp -r /var/lib/mysql /data/mysql
  3. Update /etc/my.cnf by changing the location to where you have copied mysql directory:

    # vi /etc/my.cnf
    datadir=/data/mysql
  4. Restart mysqld :

    # service mysqld restart

Note: Be sure that the path to socket mysql.sock is unchanged in my.cnf and it is /var/lib/mysql .Also the directory /var/lib/mysql itself should present on the server as changing the path to the socket can cause Plesk crush.

Have more questions? Submit a request
Please sign in to leave a comment.