"ERROR 2002 (HY000): /tmp/mysql.sock" How to fix it ? Ubuntu 12.04

May 29, 2015 2.6k views
MySQL Control Panels Ubuntu

I try change my password, but show this. how to to fix it ?

*root@TS3:~/serverpug# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)*

My system is Ubuntu 12.04

3 Answers

Check that mysql is running with "service mysql status" and if you're not sure jsut do "service mysql start" and then try again.

Show This:

root@TS3:~/serverpug# service mysql status
mysql stop/waiting
root@TS3:~/serverpug# service mysql start
start: Job failed to start
root@TS3:~/serverpug#

D ;

my sites are down about 12 hours due this problem. mysql server is running. please advise

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2017-11-21 00:39:38 UTC; 6s ago
  Process: 5085 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 5076 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 5084 (mysqld)
    Tasks: 13
   Memory: 104.7M
      CPU: 270ms
   CGroup: /system.slice/mysql.service
           └─5084 /usr/sbin/mysqld

Nov 21 00:39:08 ubuntu-1gb-fra1-01 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Nov 21 00:39:08 ubuntu-1gb-fra1-01 systemd[1]: Stopped MySQL Community Server.
Nov 21 00:39:08 ubuntu-1gb-fra1-01 systemd[1]: Starting MySQL Community Server...
Nov 21 00:39:38 ubuntu-1gb-fra1-01 systemd[1]: Started MySQL Community Server.
root@ubuntu-1gb-fra1-01:/etc/mysql# service mysql status
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2017-11-21 00:39:38 UTC; 33s ago
  Process: 5085 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 5076 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 5084 (mysqld)
    Tasks: 13
   Memory: 107.6M
      CPU: 281ms
   CGroup: /system.slice/mysql.service
           └─5084 /usr/sbin/mysqld

Nov 21 00:39:08 ubuntu-1gb-fra1-01 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Nov 21 00:39:08 ubuntu-1gb-fra1-01 systemd[1]: Stopped MySQL Community Server.
Nov 21 00:39:08 ubuntu-1gb-fra1-01 systemd[1]: Starting MySQL Community Server...
Nov 21 00:39:38 ubuntu-1gb-fra1-01 systemd[1]: Started MySQL Community Server.

Have another answer? Share your knowledge.