Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

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

I'm getting this error

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

even though I have managed to start mysql via command line in ubuntu

mysql stop/waiting
mysql start/running, process 17691

However when attempting to access the site I get a database connection error as well as the above error when trying to access mysql via mysql -u root -p

I checked my error logs and I saw this

    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's the first time I see this error and I'm not sure how to solve this issue, please help me out a bit here.

Thanks

UPDATE

Okay I tried glglgl's solution and after a restart, I get the following in the error log:

    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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

My problem was solved checking if the process was running on Ubuntu 12.04

ps ax | grep mysql

Then the answer was that it wasn't running, so I did

sudo service mysql start

Or try

sudo /etc/init.d/mysql start

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...