ERROR 2002 (HY000): No se puede conectar al servidor MySQL local a través del socket '/var/run/mysqld/mysql.sock' (2)

Estoy recibiendo este error

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

aunque he conseguido iniciar mysql a través de la línea de comandos en ubuntu

mysql stop/waiting
mysql start/running, process 17691

Sin embargo, al intentar acceder al sitio me da un error de conexión a la base de datos, así como el error anterior al intentar acceder a mysql a través de mysql -u root -p.

He comprobado mis registros de errores y he visto esto

    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)

Es la primera vez que veo este error y no estoy seguro de cómo resolver este problema, por favor, ayúdame un poco aquí.

Gracias

ACTUALIZACIÓN

Vale he probado la solución de glglgl's y después de reiniciar, me sale lo siguiente en el registro de errores:

    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)

Mi problema se solucionó comprobando si el proceso se estaba ejecutando en Ubuntu 12.04

ps ax | grep mysql

Entonces la respuesta fue que no se estaba ejecutando, así que hice

sudo service mysql start

O intente

sudo /etc/init.d/mysql start
Comentarios (5)

Tuve el mismo problema cuando instalé xampp en mi sistema. El servidor mysql busca /var/run/mysqld/mysqld.sock pero el archivo mysql.sock estaba en la carpeta xampp así que usé

 find / -name '*.sock'

para encontrar el archivo mysql.sock y luego usé

ln -s  /var/run/mysqld/mysqld.sock

para obtener un enlace para el archivo *.sock y luego trató de mysql y se ejecutó sin error. Espero que esto pueda resolver el tuyo.

Recuerda crear el directorio si no existe;

Comentarios (1)

Si te fijas bien, verás la diferencia:

  • El servidor escucha en /var/run/mysqld/mysqld.sock.
  • El cliente intenta conectarse a /var/run/mysqld/mysql.sock.

Tendrá que ajustar uno u otro.

Comentarios (2)