HOW TO CHANGE MYSQL DATA DIRECTORY Print

  • 0

NOTE: DO NOT perform this action on anything but brand new servers as contamination of InnoDB tables is sure to happen and crash your MySQL InnoDB server

Stop mysql --> # service mysql stop

Move MySQL files to the target folder --> # mv /var/lib/mysql/ /targetfolder/

Note: Target folder may be kept on a second hard disk drive

Link the original mysql folders to the new target folder --> ln -s /targetfolder/mysql /var/lib/

Test that it is working --> ls -la /var/lib/mysql

Anticipated outcome to be similar to: lrwxrwxrwx 1 root root 16 Jul 2 04:23 /var/lib/mysql -> /targetfolder/mysql/

Start MySQL back up --> service mysql start


That's it - it should be all good now and can be tested by creating a database in an applicable cPanel and see if the folder for new database populates the target folder ... if so your good to go

Was this answer helpful?

« Back