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

Sto ricevendo questo errore

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

anche se sono riuscito ad avviare mysql tramite linea di comando in ubuntu

mysql stop/waiting
mysql start/running, process 17691

Tuttavia, quando tento di accedere al sito ottengo un errore di connessione al database così come l'errore di cui sopra quando provo ad accedere a mysql tramite mysql -u root -p.

Ho controllato i miei log degli errori e ho visto questo

    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)

È la prima volta che vedo questo errore e non sono sicuro di come risolvere questo problema, per favore aiutatemi un po'.

Grazie

AGGIORNAMENTO

Ok ho provato la soluzione di glglgl'e dopo un riavvio, ottengo quanto segue nel log degli errori:

    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)

Il mio problema è stato risolto controllando se il processo era in esecuzione su Ubuntu 12.04

ps ax | grep mysql

Poi la risposta è stata che non era in esecuzione, quindi ho fatto

sudo service mysql start

Oppure prova

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

Ho avuto lo stesso problema quando ho installato xampp sul mio sistema. Il server mysql cerca /var/run/mysqld/mysqld.sock ma il file mysql.sock era nella cartella xampp quindi ho usato

 find / -name '*.sock'

per trovare il file mysql.sock e poi ho usato

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

per ottenere un link per il file *.sock poi ho provato mysql e ha funzionato senza errori. Spero che questo possa risolvere il vostro.

Ricordatevi di creare la directory se non esiste;

Commentari (1)

Se guardate da vicino, vedrete la differenza:

  • Il server ascolta su /var/run/mysqld/mysqld.sock.
  • Il client cerca di connettersi a /var/run/mysqld/mysql.sock.

Dovrai regolare l'uno o l'altro.

Commentari (2)