升级 Ubuntu,无法连接到 MySQL 服务器

升级 Ubuntu,无法连接到 MySQL 服务器

当我尝试连接到 MySQL 时,出现以下错误:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

这似乎是一个常见错误,因为我在 Google 上搜索了它并发现了很多回复。我尝试了很多回复来修复它,以下是我收到的各种错误消息:

运行 service mysql start 时:

start: Rejected send message, 1 matched rules; type="method_call", sender=":1.10" (uid=1002 pid=5788 comm="start) interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))

运行 mysqld -P 3305 时:

101115 11:06:02 [Warning] Can't create test file /var/lib/mysql/ubuntu.lower-test
101115 11:06:02 [Warning] Can't create test file /var/lib/mysql/ubuntu.lower-test
101115 11:06:02 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
101115 11:06:02 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
101115 11:06:02  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.

运行 ps -ef | grep mysql 时:

victor    5809  5688  0 11:08 pts/0    00:00:00 grep --color=auto mysql

我尝试清除 MySQL 并重新安装它,但每次都会出现同样的错误。

一切都运行良好,但我升级了 Ubuntu 服务器软件,一切就不再起作用了。

答案1

cp /etc/mysql/my.cnf.dpkg-dist /etc/mysql/my.cnf

调用-rc.d mysql 启动

答案2

检查您的 MySQL datadir 权限。

相关内容