MySQL 错误 - 无法通过套接字连接到本地 MySQL 服务器

MySQL 错误 - 无法通过套接字连接到本地 MySQL 服务器

有时我的 VPS 会收到错误

Warning: mysql_pconnect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) in /var/www/mysql.php on line 8

可以通过多次重启 MySQL、重新启动服务器或有时使用mysqld命令。

使用mysqld命令我得到以下信息:

root@web:~# mysqld
130109 10:47:23 [Note] Plugin 'FEDERATED' is disabled.
130109 10:47:23 InnoDB: The InnoDB memory heap is disabled
130109 10:47:23 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130109 10:47:23 InnoDB: Compressed tables use zlib 1.2.3.4
130109 10:47:23 InnoDB: Initializing buffer pool, size = 128.0M
130109 10:47:23 InnoDB: Completed initialization of buffer pool
130109 10:47:23 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
130109 10:47:23  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
130109 10:47:24  InnoDB: Waiting for the background threads to start
130109 10:47:25 InnoDB: 1.1.8 started; log sequence number 43428438
130109 10:47:25 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130109 10:47:25 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
130109 10:47:25 [Note] Server socket created on IP: '0.0.0.0'.
130109 10:47:25 [Note] Event Scheduler: Loaded 0 events
130109 10:47:25 [Note] mysqld: ready for connections.
Version: '5.5.28-0ubuntu0.12.04.3'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
130109 10:47:25 [ERROR] mysqld: Table './sever/table' is marked as crashed and should be repaired
130109 10:47:25 [ERROR] mysqld: Table './sever/table' is marked as crashed and should be repaired
130109 10:47:25 [ERROR] mysqld: Table './sever/table' is marked as crashed and should be repaired
130109 10:47:25 [Warning] Checking table:   './sever/table'

我每天只有 50 位访客,每小时使用超过 3000 个查询。我的 VPS 只有 1 个核心,256MB 内存,运行在 Ubuntu 64 位上。

MySQL 停机直接影响我的网站,而且我无法在任何地方找到答案。

提前致谢 :)

答案1

检查你的日志,你的表正在崩溃..

您应该先修复它,然后再继续。请参阅此链接如何做到这一点

还要检查 [hostname].err MySQL 错误日志文件。它可能位于 /var/lib/mysql 或 /var/log/syslog 中

答案2

您应该查看日志(mysql 错误日志、mysql 查询日志、系统日志)条目当系统出现故障时重新启动后就不会了。

您可能已达到最大连接数限制。

每天只有 50 位访客,每小时使用超过 3000 个查询

erk,这个数字太高了,即使你使用 Hibernate(但你没有提到 Web 服务器和 MySQL 之间有什么)。

我会查看这段时间的网络流量情况 - 速度是否变慢 - 是否交换了太多内容 - 到底有多少用户处于连接状态。在尝试重新启动 mysqld 进程之前,还要检查它的情况 - 该进程是否仍然存在?

相关内容