I want to have a SQL script run whenever mysql starts but I can't get it working in Ubuntu 11.10.
I added a "init-file" option to the mysql config file:
> sudo emacs -nw /etc/mysql/my.cnf
...
[mysqld]
init-file=/etc/mysql/mysqlinit.sql
...
But when I restart mysql, it fails with a "File not found" error:
> tail /var/log/mysql/error.log
111111 7:41:06 [ERROR] /usr/sbin/mysqld: File '/etc/mysql/mysqlinit.sql' not found (Errcode: 13)
111111 7:41:06 [ERROR] Aborting
But the file certainly exists and is readable:
> ls -l /etc/mysql/mysqlinit.sql
-rwxr-xr-x 1 mysql mysql 30 2011-11-09 05:06 /etc/mysql/mysqlinit.sql
Any ideas how to solve this? Is this a Ubuntu oddness or did I do something dumb?
Info:
I'm running Ubuntu 11.10 and MySQL 5.1.
> mysqld --version
mysqld Ver 5.1.58-1ubuntu1 for debian-linux-gnu on x86_64 ((Ubuntu))
Thanks @quanta, the problem was indeed apparmor.
To fix the issue:
Edit the mysql apparmor file:
Include the folder where your init-file lives with the *.sql extension:
And then make AppArmor reload the profiles.
Then reload mysql:
Now the init-file gets executed. Yay!