调试 MySQL 连接错误

调试 MySQL 连接错误

我在一台机器上安装了 Ubuntu 10.04 LTS 作为 LAMP 服务器。我的 MySQL 连接时不时会断开,并且会收到以下错误消息:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

此后我必须重新启动服务器才能使其重新运行。

似乎没有警告就发生了。调试此问题的最佳方法是什么?我对 Linux 命令行还很陌生,所以请温柔一点。

编辑:查看 mysql 日志后,我发现了以下内容:

100813 18:56:16 [Note] Plugin 'FEDERATED' is disabled.
100813 18:56:16  InnoDB: Started; log sequence number 0 44233
100813 18:56:16 [ERROR] Column count of mysql.db is wrong. Expected 22, found 20. The table is probably corrupted
100813 18:56:16 [ERROR] mysql.user has no `Event_priv` column at position 29
100813 18:56:16 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.
100813 18:56:16 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.41-3ubuntu12'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
100813 18:56:17 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

答案1

看起来你的 mysql 服务器压垮了并且删除了套接字,看一下 mysql 服务器日志它应该可以指出什么问题。

编辑:

好的,这表明你的用户表已损坏,请尝试修复它

mysql
use mysql
repair table user

相关内容