Move the MySQL data directory

less than 1 minute read

Today I got my new Cubieboard. I installed Debian Wheezy on a 4 GB SD Card, but the Cubieboard also has built-in NAND memory. I wanted to place all the data for the webserver on the NAND memory for faster access. Everything went well except for moving the MySQL data directory.

At first, I just edited /etc/mysql/my.cnf, changed datadir = /var/lib/mysql to datadir = /nanda/mysql and moved the data directory to the NAND memory. MySQL wouldn’t start anymore.

The solution was pretty easy. I just had to reinitilize the MySQL databases (mysql_install_db --user=mysql --ldata=/nanda/mysql). After that, I restarted MySQL and it worked!

In my case I had to reboot the whole system because I couldn’t access my databases trough PHP. This may be caused by the many attempts I have made to fix this problem.

Updated:

Leave a comment