I'estou a receber este erro
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2)
apesar de ter conseguido iniciar o mysql via linha de comando no ubuntu
mysql stop/waiting
mysql start/running, process 17691
Entretanto, ao tentar acessar o site, recebo um erro de conexão com o banco de dados, assim como o erro acima ao tentar acessar o mysql via mysql -u root -p
.
Eu verifiquei os meus registos de erros e vi isto
131029 12:53:34 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be remo$
131029 12:53:34 [Note] Plugin 'FEDERATED' is disabled.
131029 12:53:34 InnoDB: The InnoDB memory heap is disabled
131029 12:53:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131029 12:53:34 InnoDB: Compressed tables use zlib 1.2.3.4
131029 12:53:34 InnoDB: Initializing buffer pool, size = 26.0G
131029 12:53:36 InnoDB: Completed initialization of buffer pool
131029 12:53:36 InnoDB: highest supported file format is Barracuda.
131029 12:53:38 InnoDB: Waiting for the background threads to start
131029 12:53:39 InnoDB: 5.5.34 started; log sequence number 5146431500
131029 12:53:39 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
131029 12:53:39 [Note] - '0.0.0.0' resolves to '0.0.0.0';
131029 12:53:39 [Note] Server socket created on IP: '0.0.0.0'.
131029 12:53:39 [Note] Event Scheduler: Loaded 0 events
131029 12:53:39 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.34-0ubuntu0.12.04.1-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
It'é a primeira vez que eu vejo este erro e I'não tenho certeza de como resolver este problema, por favor me ajude um pouco aqui.
Obrigado
**UPDATE***
Ok, eu tentei a solução glglgl's e depois de um reinício, eu recebo o seguinte no log de erros:
131029 13:17:36 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be remo$
131029 13:17:36 [Note] Plugin 'FEDERATED' is disabled.
131029 13:17:36 InnoDB: The InnoDB memory heap is disabled
131029 13:17:36 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131029 13:17:36 InnoDB: Compressed tables use zlib 1.2.3.4
131029 13:17:36 InnoDB: Initializing buffer pool, size = 26.0G
131029 13:17:38 InnoDB: Completed initialization of buffer pool
131029 13:17:38 InnoDB: highest supported file format is Barracuda.
131029 13:17:40 InnoDB: Waiting for the background threads to start
131029 13:17:41 InnoDB: 5.5.34 started; log sequence number 5146431500
131029 13:17:41 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
131029 13:17:41 [Note] - '127.0.0.1' resolves to '127.0.0.1';
131029 13:17:41 [Note] Server socket created on IP: '127.0.0.1'.
131029 13:17:41 [Note] Event Scheduler: Loaded 0 events
131029 13:17:41 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.34-0ubuntu0.12.04.1-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
O meu problema foi resolvido verificando se o processo estava a decorrer no Ubuntu 12.04
ps ax | grep mysql
Então a resposta foi que era't running, então eu fiz
sudo service mysql start
Ou tente
sudo /etc/init.d/mysql start
Eu tive o mesmo problema quando instalei o xampp no meu sistema. O servidor mysql procura por /var/run/mysqld/mysqld.sock mas o arquivo mysql.sock estava na pasta xampp então eu usei
find / -name '*.sock'
para encontrar o arquivo mysql.sock e depois usar o
ln -s <the file location> /var/run/mysqld/mysqld.sock
para obter um link para o arquivo *.sock, em seguida, tentou o mysql e ele correu sem erros. Espero que isto possa resolver o seu.
Lembre-se de criar o diretório se ele não existir.