Reputation: 2217
I need to change my datadir and I have succeeded to do so on the main HDD. I tried the same manipulation on another mounted HDD and restarting the mysql fails, I don't understand why. Here is the manipulation I made:
editing the my.cnf :
datadir = /var/lib/mysql -> datadir = /media/user/BCB3A.../mysql
copying mysql data to the new folder:
sudo -s
/etc/init.d/mysql stop
cp -pr /var/lib/mysql/* /media/user/BCB3A.../mysql
editing apparmor:
/var/lib/mysql/ r, -> /media/user/BCB3A.../mysql/ r,
/var/lib/mysql/** rwk, -> /media/user/BCB3A/mysql/** rwk,
restarting the services :
sudo /etc/init.d/apparmor restart
sudo /etc/init.d/mysql start
Apparmor restarts properly, but mysql fails.
Looks like I have an issue in the mounting parameters of HDD2 but I don't know what, any idea?
Upvotes: 2
Views: 1362
Reputation: 2217
The answer is pretty simple actually....
The mysql folder needs to be owned by mysql:mysql. sudo chown mysql:mysql /your_new_mysql_dir/
In my case this command was not changing the ownership for the simple reason that the file system of the secondary hard disk drive was NTFS, and permissions/ownership is not applyable on NTFS, so a format into FAT32 fixed the issue. Thanks to @hek2mgl for the big help!
Upvotes: 2