我有一个运行 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.0
and 127.0.1.1
(这一行是因为我127.0.1.1 foo
的其中一行是我的虚拟机的主机名),/etc/hosts
它是我的网络上计算机的实际内部 IP。他们都没有任何区别。我还尝试注释掉该行以进行良好的衡量,同上。foo
10.1.1.213
bind-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