Can't connect to local MySQL server through socket '/tmp/mysql.sock'
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
錯誤提示:
~]# mysql --socket=/tmp/mysql.sock
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解決方法:
由於mysql 預設的mysql.sock 是在/var/lib/mysql/mysql.sock,但linux系統總是去/tmp/mysql.sock查詢,所以會報錯
[root@localhost ~]# find / -name mysql.sock
/var/lib/mysql/mysql.sock
1.直接指定mysql通道
[root@localhost ~]# mysql --socket=/var/lib/mysql/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 2 to server version: 5.0.22
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>
2. 建立符號連線:
為mysql.sock增加軟連線(相當於windows中的快捷方式)。
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
eg:
~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@localhost ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 3 to server version: 5.0.22
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>
我覺得這兩個方法挺好用的
----end----
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30633755/viewspace-1871660/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 解決Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2) "MySqlServer
- Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock錯誤MySqlServer
- MySQL連線提示Can't connect to local MySQL server through socketMySqlServer
- Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)解決方法MySqlServer
- mysql 啟動報錯Can't connect to local MySQL server through socket '/data/mysql/mysql/mysql.sock'(111)MySqlServer
- ERROR 2002(HY000):Can't connect to local MySQL socket '/tmp/mysql.sock'ErrorMySql
- ERROR 2002 (HY000): Can't connect server socket /tmp/mysql.sockErrorServerMySql
- MySQL 5.5 關閉資料庫報錯"Can't connect to local MySQL server through socket"MySql資料庫Server
- mysqldump: Got error: 2002: Can't connect to local MySQL server through.....MySqlGoErrorServer
- MySQL報錯'ERROR 2002 (HY000): Can't connect to local MySQL server through'MySqlErrorServer
- 更換mysql資料目錄後出現ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 的解決辦法MySqlErrorServer
- linux下連線mysql報錯ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysqLinuxMySqlErrorServer
- ERROR 2002 (HY000): Cant connect to local MySQL server through socket的解決方法ErrorMySqlServer
- 異常:Can't connect to MySQL server (10060)MySqlServer
- 連線MySQL錯誤:Can't connect to MySQL server (10060)MySqlServer
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- [jenkins]Can’t connect to window server – not enough permissionsJenkinsServer
- Can't connect to X11 window server usingServer
- mysql [ERROR] Can't create IP socket: Permission deniedMySqlError
- ERROR 2002 (HY000): Can't connect server socket /var/run/mysqld/mysqld.sockErrorServerMySql
- MySQL問題記錄--Can't connect to MySQL server on localhost (10061)解決方法MySqlServerlocalhost
- 【linux】Can't connect to MySQL server on 'XXX' (13)問題解決方式LinuxMySqlServer
- mysql can't connect error about privilege----not root userMySqlError
- Can't connect to X11 window server using DISPLAY variableServer
- Can't connect to X11 window server using '127.0.0.1:0.0'Server127.0.0.1
- ERROR 2003 (HY000)Can't connect to MySQL server on '192.168.8.247' (113)ErrorMySqlServer
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)ErrorMySqlServerlocalhost
- Can'tconnecttolocalMySQLserverthroughsocket'/var/lib/mysql/mysql.sock'(2)MySqlServer
- 解決svnserve: Can't bind server socket: Address already in useServer
- Can't Connect to MySQL Server on IP Address (10061) 錯誤的解決方案MySqlServer
- error:'Can'tconnecttolocalMySQLserverthroughsocket'/var/lib/mysql/mysql.sock'(2)'ErrorMySqlServer
- MySQL不能啟動 Can't start server : Bind on unix sockeMySqlServer
- Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.Server
- java.lang.InternalError: Can't connect to X11 window server using ':0.0' asJavaErrorServer
- 啟動mysql時顯示:/tmp/mysql.sock 不存在的解決方法MySql
- MySQL 5.5 原始碼安裝報錯"[ERROR] Can't start server"MySql原始碼ErrorServer
- Navicat 連線 MySQL 失敗:2002-can‘t connect to server on localhost(10061)問題解決MySqlServerlocalhost
- Error:Can't connect to SOCKS proxy:Connection refused (Connection refused)Error