无法在最近升级的虚拟机上启动 MySQL 服务

无法在最近升级的虚拟机上启动 MySQL 服务

我有一个运行 Ubuntu 服务器的 VM,我刚刚升级到 14.04。 VM 提供对 MySQL 数据库的访问。但是,升级后,数据库拒绝启动,我对此了解不够,无法弄清楚:

root@vm-1 ~ $ service mysql start
start: Job failed to start

我查了一下/var/log/mysql/error.log,发现:

141001 20:23:10 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
141001 20:23:10 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
141001 20:23:10 [Note] Server socket created on IP: '127.0.0.1'.
141001 20:23:10 [ERROR] Can't start server : Bind on unix socket: Permission denied
141001 20:23:10 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
141001 20:23:10 [ERROR] Aborting

141001 20:23:10  InnoDB: Starting shutdown...
141001 20:23:11  InnoDB: Shutdown completed; log sequence number 24590151085
141001 20:23:11 [Note] /usr/sbin/mysqld: Shutdown complete

您可以找到该文件的全部内容这里。请注意,我在运行上面显示的命令之前删除了它service,因此所有内容都来自于一次启动 MySQL 服务的尝试。

我还检查了显而易见的事情:

$ ps ax | grep mysql
 3623 pts/1    S+     0:00 grep --color mysql
$ rm /var/run/mysqld/mysqld.sock
rm: cannot remove ‘/var/run/mysqld/mysqld.sock’: No such file or directory
$ netstat | grep 3306

我确保数据库目录具有正确的权限:

$ chown -R mysql:root /data/database/

我尝试跑步strace,但看不到任何明显的东西。不过我对它了解甚少,所以你可以找到输出这里

最后,我的/etc/mysql/my.cnf是:

[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0
[mysqld]
user        = mysql
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /data/database
tmpdir      = /tmp
skip-external-locking
bind-address        = 127.0.0.1
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
myisam-recover         = BACKUP
query_cache_limit   = 1M
query_cache_size        = 16M
log_error                = /var/log/mysql/error.log
expire_logs_days    = 10
max_binlog_size         = 100M
[mysqldump]
quick
quote-names
max_allowed_packet  = 16M
[mysql]
[isamchk]
key_buffer      = 16M
!includedir /etc/mysql/conf.d/

我尝试将bind-address上面的行更改为0.0.0.0, 127.0.0.0and 127.0.1.1(这一行是因为我127.0.1.1 foo的其中一行是我的虚拟机的主机名),/etc/hosts它是我的网络上计算机的实际内部 IP。他们都没有任何区别。我还尝试注释掉该行以进行良好的衡量,同上。foo10.1.1.213bind-address

我的系统详细信息:

$ cat /etc/issue
Ubuntu 14.04.1 LTS \n \l

$ dpkg -s mysql-server | grep version
Version: 5.5.38-0ubuntu0.14.04.1

答案1

这个问题确实与apparmor有关。由于某种原因,这两行在新文件中被注释掉了/etc/apparmor.d/usr.sbin.mysql

#  /var/lib/mysql/ r,  
#  /var/lib/mysql/** rwk,

取消注释它们解决了问题。谢谢@贝尔罗格@slm谁给我指明了正确的方向。

相关内容