我想在
mysql启动时运行一个sql脚本,但我无法在Ubuntu 11.10中运行它.
我在MysqL配置文件中添加了一个“init-file”选项:
> sudo emacs -nw /etc/MysqL/my.cnf ... [MysqLd] init-file=/etc/MysqL/MysqLinit.sql ...
但是,当我重新启动MysqL时,它失败并显示“找不到文件”错误:
> 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
但该文件肯定存在且可读:
> ls -l /etc/MysqL/MysqLinit.sql -rwxr-xr-x 1 MysqL MysqL 30 2011-11-09 05:06 /etc/MysqL/MysqLinit.sql
任何想法如何解决这个问题?这是一个Ubuntu奇怪还是我做了一些愚蠢的事情?
信息:
我正在运行Ubuntu 11.10和MysqL 5.1.
> MysqLd --version MysqLd Ver 5.1.58-1ubuntu1 for debian-linux-gnu on x86_64 ((Ubuntu))
谢谢@quanta,问题确实是apparmor.
原文链接:https://www.f2er.com/ubuntu/348895.html要解决此问题:
sudo emacs -nw /etc/apparmor.d/usr.sbin.MysqLd
... /usr/sbin/MysqLd { /var/log/MysqL.log rw,/var/log/MysqL.err rw,;/var/lib/MysqL/ r,/var/lib/MysqL/** rwk,/var/log/MysqL/ r,/var/log/MysqL/* rw,/{,var/}run/MysqLd/MysqLd.pid w,var/}run/MysqLd/MysqLd.sock w,/sys/devices/system/cpu/ r,# I added to allow my init-file script to run /etc/MysqL/*.sql r,}
然后让AppArmor重新加载配置文件.
# sudo /etc/init.d/apparmor reload
然后重新加载MysqL:
sudo /etc/init.d/MysqL restart
现在init文件被执行了.好极了!