红联Linux门户
Linux帮助

ubuntu14.04无法启动mysql的解决过程

发布时间:2016-10-25 10:05:16来源:linux网站作者:wilelm
环境:
OS:Ubuntu 14.04.1 LTS
Kernal:3.13.0-93-generic
 
过程:
apt-get install mysql-server  
 
安装完后,修改了/etc/mysql/my.cf中的datadir指向一个挂载的硬盘上的目录,然后重启服务。
/etc/init.d/mysql restart  
 
提示启动failed,查看日志,报如下错误:
161024 17:46:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql  
161024 17:46:54 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.  
161024 17:46:54 [Note] /usr/sbin/mysqld (mysqld 5.5.52-0ubuntu0.14.04.1) starting as process 12834 ...  
161024 17:46:54 [Warning] Can't create test file /var/lib/mysql/host150.lower-test  
161024 17:46:54 [Warning] Can't create test file /var/lib/mysql/host150.lower-test  
161024 17:46:54 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.  
161024 17:46:54 [Note] Plugin 'FEDERATED' is disabled.  
/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)  
161024 17:46:54 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.  
161024 17:46:54 InnoDB: The InnoDB memory heap is disabled  
161024 17:46:54 InnoDB: Mutexes and rw_locks use GCC atomic builtins  
161024 17:46:54 InnoDB: Compressed tables use zlib 1.2.8  
161024 17:46:54 InnoDB: Using Linux native AIO  
161024 17:46:54 InnoDB: Initializing buffer pool, size = 128.0M  
161024 17:46:54 InnoDB: Completed initialization of buffer pool  
161024 17:46:54  InnoDB: Operating system error number 13 in a file operation.  
InnoDB: The error means mysqld does not have the access rights to  
InnoDB: the directory.  
InnoDB: File name ./ibdata1  
InnoDB: File operation call: 'open'.  
InnoDB: Cannot continue operation.  
161024 17:46:54 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended  
 
原以为是系统目录权限的问题,修改了目录权限。
chown -R mysql:mysql /data/mysql  
chmod -R 755 /data/mysql  
 
再次尝试启动,还是不行。
 
最后搜索到一个解决办法:
/etc/init.d/apparmor stop  
/etc/init.d/apparmor teardown  
update-rc.d -f apparmor remove  
apt-get purge apparmor  
reboot
再次启动就ok了。
 
查了一下apparmor,是一个加入内核的巩固Linux内核安全的软件,卸载掉这个应该不是一个好的解决办法,如果大家有什么更好的办法,欢迎指点。
 
说明一下,我后来把/data/MySQL做为软链到了/var/lib目录。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/25372.html