I have an EC2 instance set up and I'm trying to move the MySQL data directory to mounted storage.
The default data directory is:
/opt/bitnami/mysql/data
I've copied that directory entirely to
/mnt/mysql_data
Then I changed the path in my.cnf to the following:
datadir=/mnt/mysql_data
and renamed the old directory to be sure I'm using the new one.
I've given proper permissions to MySQL on the new directory – but I don't even think MySQL is trying to get there. When I try to restart mysql I get errors about the previous data directory:
sudo /opt/bitnami/ctlscript.sh start mysql
111122 18:50:50 mysqld_safe Logging to '/opt/bitnami/mysql/data/mysqld.log'.
touch: cannot touch `/opt/bitnami/mysql/data/mysqld.log': No such file or directory
chown: cannot access `/opt/bitnami/mysql/data/mysqld.log': No such file or directory
111122 18:50:50 mysqld_safe Starting mysqld.bin daemon with databases from /opt/bitnami/mysql/data
/opt/bitnami/mysql/bin/mysqld_safe: 739: cannot create /opt/bitnami/mysql/data/mysqld.log: Directory nonexistent
eval: 1: cannot create /opt/bitnami/mysql/data/mysqld.log: Directory nonexistent
111122 18:50:50 mysqld_safe mysqld from pid file /opt/bitnami/mysql/data/ip-10-120-253-190.pid ended
/opt/bitnami/mysql/bin/mysqld_safe: 783: cannot create /opt/bitnami/mysql/data/mysqld.log: Directory nonexistent
Am I missing a configuration step somewhere? I've seen others with issues solve it by adjusting apparmor, but I don't even have the file "/etc/apparmor.d/usr.sbin.mysqld" that they're supposed to be changing. Plus, my problem doesn't seem to be that mysql can't access the new directory – it's that it's still using the old one.
Best Answer
Turns out Amazon's control script "/opt/bitnami/ctlscript.sh" is executing a mysql config script at /opt/bitnami/mysql/scripts/ctl.sh
Annoyingly, this script overrides a few key settings from the my.cnf file. Updating them there fixes the issue.