ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 에러를 만났을때

운영중인 서비스가 갑자기 이런 에러가 나더니 서비스 자체 운영이 안되었다. 이 문제의 원인과 해결책에 대한 문제이다.

2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 에러를 만났을때




1. MySQL데몬이 기동이 되어 있지 못한다.

2. my.cnf파일자체가 깨졌을 경우 해당 메시지를 만난다.



kangdr@kangdr-K8VM890:~$ sudo /usr/bin/mysqld_safe --user=mysql&
[1] 7118

그 다음 데이타베이스의 상태를 확인

kangdr@kangdr-K8VM890:~$ sudo service mysql state
[sudo] password for kangdr: 
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql state

The script you are attempting to invoke has been converted to an Upstart
job, but state is not supported for Upstart jobs.

[1]+  Stopped                 sudo /usr/bin/mysqld_safe --user=mysql
kangdr@kangdr-K8VM890:~$ 140430 09:25:13 mysqld_safe Logging to '/var/lib/mysql/kangdr-K8VM890.err'.
140430 09:25:13 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140430 09:25:18 mysqld_safe mysqld from pid file /var/lib/mysql/kangdr-K8VM890.pid ended

[2]-  Done                    sudo /usr/bin/mysqld_safe --user=mysql
kangdr@kangdr-K8VM890:~$ ln -s /tmp/mysqld.sock /var/lib/mysql/mysql.sock
ln: accessing `/var/lib/mysql/mysql.sock': Permission denied
kangdr@kangdr-K8VM890:~$ sudo ln -s /tmp/mysqld.sock /var/lib/mysql/mysql.sock


다른 시도

kangdr@kangdr-K8VM890:~$ ps -ef|grep -i mysql
root      7118  6968  0 09:20 pts/0    00:00:00 sudo /usr/bin/mysqld_safe --user=mysql
kangdr    7464  6968  0 09:34 pts/0    00:00:00 grep --color=auto -i mysql

현재 프로세스 확인


또 다른 시도(참조한 페이지)

angdr@kangdr-K8VM890:~$ sudo  mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/
Installing MySQL system tables...
Filling help tables...

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

To do so, start the server, then issue the following commands:

/usr//bin/mysqladmin -u root password 'new-password'
/usr//bin/mysqladmin -u root -h kangdr-K8VM890 password 'new-password'

Alternatively you can run:

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/ ; /usr//bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr//mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr//scripts/mysqlbug script!


또다른 시도

kangdr@kangdr-K8VM890:~$ ps aux | grep mysql
root      7118  0.0  0.0  54836  1700 pts/0    T    09:20   0:00 sudo /usr/bin/mysqld_safe --user=mysql
kangdr    7968  0.0  0.0  10484   904 pts/0    S+   09:46   0:00 grep --color=auto mysql
kangdr@kangdr-K8VM890:~$ kill -9 7118
-bash: kill: (7118) - Operation not permitted
kangdr@kangdr-K8VM890:~$ sudo kill -9 7118
[1]+  Killed                  sudo /usr/bin/mysqld_safe --user=mysql

또다른 시도

Ubuntu 11.10:  sudo dpkg-reconfigure mysql-server-5.1

Ubuntu 12.04:  sudo dpkg-reconfigure mysql-server-5.5

Follow instruction then reboot.

This problem may happen when you upgrade from one ubuntu version to another and config gets messed up somehow. Usually the related to the startup process of mysql daemon mysqld)


kangdr@kangdr-K8VM890:~$ sudo mysql_install_db
Installing MySQL system tables...
ERROR: 1004  Can't create file '/tmp/#sql1fa2_1_0.frm' (errno: 9)
140430  9:50:08 [ERROR] Aborting

140430  9:50:08 [Note] /usr/sbin/mysqld: Shutdown complete

Installation of system tables failed!  Examine the logs in
/var/lib/mysql for more information.

You can try to start the mysqld daemon with:

    shell> /usr/sbin/mysqld --skip-grant &

and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> /usr/bin/mysql -u root mysql
    mysql> show tables

Try 'mysqld --help' if you have problems with paths.  Using --log
gives you a log in /var/lib/mysql that may be helpful.

Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.

Please check all of the above before mailing us!  And remember, if
you do mail us, you MUST use the /usr/bin/mysqlbug script!


댓글 본문
버전 관리
현재 버전
선택 버전
graphittie 자세히 보기