ERROR 2002(HY000):Can't connect to local MySQL socket '/tmp/mysql.sock'
公司要使用MySQL,我就開始玩MySQL,可是跟想象中的不一樣,問題頗多,只能慢慢享受了。之前就透過編譯的方式安裝好MySQL5.7。
今天登陸的時候遇見一的問題,記錄一下
[root@testmysql bin]# ./mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解決方法:
由於mysql 預設的mysql.sock 是在/usr/local/mysql/data/mysql.sock,但linux系統總是去/tmp/mysql.sock查詢,所以會報錯
1.直接指定mysql通道
據我知道的(ps:我是菜鳥,請糾正),老版本(5.4之前)的是:/var/lib/mysql/mysql.sock
在新版本中預設是在/usr/local/mysql/data/mysql.sock,具體的可以去檢視my.cnf檔案裡面
[root@testmysql bin]# ./mysql --socket=/usr/local/mysql/data/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.4-m7 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
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@testmysql bin]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
插曲:有可能你在建立連線的時候出現下面的情況,
[root@testmysql bin]# ln -vs /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
ln: creating symbolic link `/tmp/mysql.sock': File exists
沒關係,加上-f引數就可以了。-f的主要過程:先將同名的軟連結dd刪除,然後再建立硬連結dd
[root@testmysql bin]# ln -f /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
[root@testmysql bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.4-m7 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30936525/viewspace-2016620/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux下連線mysql報錯ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysqLinuxMySqlErrorServer
- Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock錯誤MySqlServer
- mysql 啟動報錯Can't connect to local MySQL server through socket '/data/mysql/mysql/mysql.sock'(111)MySqlServer
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- Error:Can't connect to SOCKS proxy:Connection refused (Connection refused)Error
- Navicat 連線 MySQL 失敗:2002-can‘t connect to server on localhost(10061)問題解決MySqlServerlocalhost
- Error!: SQLSTATE[HY000] [2002] Connection refusedErrorSQL
- [ERROR] mysqld: Can‘t open shared library ‘/usr/local/mysql/lib/plugin/validate_password.so‘ (errno:ErrorMySqlPlugin
- Can't Connect to MySQL Server on IP Address (10061) 錯誤的解決方案MySqlServer
- docker phpmyadmin 連線宿主mysql資料庫報錯:mysqli::real_connect(): (HY000/2002): Connection refusedDockerPHPMySql資料庫
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- ERROR 1290 (HY000): The MySQL server is running withErrorMySqlServer
- [mac pip錯誤]Can't connect to HTTPS URL because the SSL module is not availableMacHTTPAI
- Mysql連線錯誤ERROR 2003 (HY000)MySqlError
- Fatal error: can't check configuration file '/home/watt/proxy/dError
- 解決ERROR 1231 (42000): Variable 'time_zone' can'tError
- 使用雲伺服器配置MariaDB環境,Navicat遠端連線一直出錯誤程式碼 "2002 - Can't connect to server on '' (10060)"伺服器Server
- ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAError
- mysql遇到Variable can’t be set to the value of ‘NULL’MySqlNull
- 【MySQL】ERROR 1878 (HY000): Temporary file write failure.MySqlErrorAI
- Mac電腦下使用Socket報錯socket丟擲Can’t assign requested address解決Mac
- GTID複製報錯處理:Last_Error: Error 'Can't drop database 'test';ASTErrorDatabase
- MySQL報錯ERROR 2013 (HY000): Lost connection to MySQL server during queryMySqlErrorServer
- 完美解決stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.ErrorPython
- ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization paErrorMySqlServer
- mysql匯入sql檔案報錯 ERROR 2013 2006 2002MySqlError
- ERROR 2026 (HY000): SSL connection error: unknown error numberError
- mysql執行報錯mysql.sockMySql
- Mysql:Variable 'XXXt' can't be set to the value of 'NULL'解決MySqlNull
- 阿里雲mysql遠端登入報ERROR 2027(HY000)阿里MySqlError
- MySQL 報錯 ERROR 1290 (HY000): running with the --secure-file-privMySqlError
- ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables optErrorMySqlServer
- MYSQL報1022錯誤:Can't write;duplicate key in table '.....'MySql
- mysql中You can’t specify target table for update in FROM clMySql
- ERROR 1114 (HY000) The table '' is fullError
- 【MySQL】ERROR 1290 (HY000): --secure-file-priv--匯出報錯MySqlError
- MySQL5.7叢集(MGR)啟動報ERROR 3092 (HY000)MySqlError
- MySQL案例02:ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGESMySqlError
- MySQL 使用 show tables 時出現 ERROR 1449 (HY000) 問題MySqlError