Eu uso o Ubuntu Server 12.04 para o meu projeto Django. No meu PC local não há erros e etc. Às vezes no servidor eu tenho erro:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
Logs:
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...
Eu vejo esse erro (2002) muitas vezes, eu não consigo entender - por que ele aparece.
Eu tento /etc/init.d/mysql restart
ou service mysql restart
, mas isso não ajuda. Eu tenho mysql-server , não um cliente. Então funciona, funciona, funciona e em um momento maravilhoso eu vejo esse erro.
ps ax | grep mysql
15654 pts/0 S+ 0:00 grep --color=auto mysql
Então, eu tento
sudo service mysql start
start: Job failed to start
Logs:
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
Como consertar isso? Como reiniciar? Por que vejo esse erro? O que há de errado?
Thaks.
UPDATE
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
e
/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