我正在尝试将我的MySQL数据库的数据目录从默认位置/ var / lib / mysql更改为新路径,在我的例子中是/home/dev/Desktop/iiab/db/mysql.
我试过跟随Victor在以下帖子中提供的答案: How to change MySQL data directory? (我还根据关于Victor答案的评论中mak的说明编辑了别名文件)。
但是,当我再次尝试启动MySQL时,我收到以下终端错误:
mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
使用以下命令检查日志文件时
tail -f /var/log/mysql/error.log
它显示以下内容:
2016-05-23T13:43:11.608141Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-05-23T13:43:11.608234Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-05-23T13:43:11.608252Z 0 [ERROR] Failed to initialize plugins.
2016-05-23T13:43:11.608260Z 0 [ERROR] Aborting
2016-05-23T13:43:11.608297Z 0 [Note] Binlog end
2016-05-23T13:43:11.608416Z 0 [Note] Shutting down plugin 'MyISAM'
2016-05-23T13:43:11.608469Z 0 [Note] Shutting down plugin 'CSV'
2016-05-23T13:43:11.609124Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
我的my.cnf文件如下所示(我省略了初始注释##):
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
datadir=/home/dev/Desktop/iiab/db/mysql
socket=/home/dev/Desktop/iiab/db//mysql.sock
我的/etc/apparmor.d/usr.sbin.mysqld文件如下所示(我只包括受指令影响的部分,即用新路径替换var / lib / mysql)。
# Allow data dir access
/home/dev/Desktop/iiab/db/mysql/ r,
/home/dev/Desktop/iiab/db/mysql/** rwk,
# Allow data files dir access
/home/dev/Desktop/iiab/db-files/ r,
/home/dev/Desktop/iiab/db-files/** rwk,
# Allow keyring dir access
/home/dev/Desktop/iiab/db-keyring/ r,
/home/dev/Desktop/iiab/db-keyring/** rwk,
我的/etc/apparmor.d/tunables/alias文件如下所示(我省略了初始注释##):
# Or if mysql databases are stored in /home:
alias /var/lib/mysql/ -> /home/dev/Desktop/iiab/db/mysql/,
我能够成功重启并重新加载apparmor。
我正在使用Ubuntu 16.04。
任何人都知道我做错了什么?