Ubuntu 12.04 mysql 问题

Ubuntu 12.04 mysql 问题

我使用 Ubuntu Server 12.04 来运行我的 Django 项目。在我的本地电脑上没有错误等。有时在服务器上我会出现错误:

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

日志:

cat /var/log/mysql/error.log
140415 23:05:34 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140415 23:05:34 [Note] Plugin 'FEDERATED' is disabled.
140415 23:05:34 InnoDB: The InnoDB memory heap is disabled
140415 23:05:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140415 23:05:34 InnoDB: Compressed tables use zlib 1.2.3.4
140415 23:05:34 InnoDB: Initializing buffer pool, size = 128.0M
140415 23:05:34 InnoDB: Completed initialization of buffer pool
140415 23:05:34 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!
140415 23:05:34  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...
140415 23:05:35 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140415 23:05:35 [Note] Plugin 'FEDERATED' is disabled.
140415 23:05:35 InnoDB: The InnoDB memory heap is disabled
140415 23:05:35 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140415 23:05:35 InnoDB: Compressed tables use zlib 1.2.3.4
140415 23:05:35 InnoDB: Initializing buffer pool, size = 128.0M
140415 23:05:35 InnoDB: Completed initialization of buffer pool
140415 23:05:35 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!
140415 23:05:35  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...

我经常看到那个错误(2002),我不明白为什么它会出现。

我尝试/etc/init.d/mysql restartservice mysql restart,但没有帮助。我有mysql 服务器,不是客户端。所以它工作、工作、工作,然后在一个美妙的时刻我看到了那个错误。

ps ax | grep mysql
15654 pts/0    S+     0:00 grep --color=auto mysql

因此,我尝试

sudo service mysql start
start: Job failed to start

日志:

140416  1:11:17 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140416  1:11:17 [Note] Plugin 'FEDERATED' is disabled.
140416  1:11:17 InnoDB: The InnoDB memory heap is disabled
140416  1:11:17 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140416  1:11:17 InnoDB: Compressed tables use zlib 1.2.3.4
140416  1:11:17 InnoDB: Initializing buffer pool, size = 128.0M

dpkg -l | grep mysql
ii  libdbd-mysql-perl                    4.020-1build2                     Perl5 database interface to the MySQL database
ii  libmysqlclient18                     5.5.35-0ubuntu0.12.04.2           MySQL database client library
ii  mysql-client-5.5                     5.5.35-0ubuntu0.12.04.2           MySQL database client binaries
ii  mysql-client-core-5.5                5.5.35-0ubuntu0.12.04.2           MySQL database core client binaries
ii  mysql-common                         5.5.35-0ubuntu0.12.04.2           MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                         5.5.35-0ubuntu0.12.04.2           MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.5                     5.5.35-0ubuntu0.12.04.2           MySQL database server binaries and system database setup
ii  mysql-server-core-5.5                5.5.35-0ubuntu0.12.04.2           MySQL database server binaries
ii  python-mysqldb                       1.2.3-1ubuntu0.1                  Python interface to MySQL

如何修复?如何重启?为什么我会看到这个错误?出了什么问题?

谢谢。

更新

grep socket /etc/mysql/my.cnf                       
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
socket      = /var/run/mysqld/mysqld.sock
#socket=/var/lib/mysql/mysql.sock
socket      = /var/run/mysqld/mysqld.sock
socket      = /var/run/mysqld/mysqld.sock

/var/run/mysqld$ ls -la
total 4
drwxr-xr-x  2 mysql root   80 Apr 13 12:06 .
drwxr-xr-x 16 root  root  520 Apr 16 01:33 ..
-rw-rw----  1 mysql mysql   4 Apr 13 12:06 mysqld.pid
srwxrwxrwx  1 mysql mysql   0 Apr 13 12:06 mysqld.sock

相关内容