linux下連線mysql報錯ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysq
首先預設已經檢視過mysql伺服器是否正常執行,和許可權設定的問題。
2002報錯大意是找不到對應檔案,不能通過這個socket連線到本地mysql。
網上大多教程多說手動修改/etc/my.cnf
檔案
有可能還沒這個檔案,那就手動建立一個,新增以下內容
[mysqld]
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
[mysql.server]
user=mysql
basedir=/usr/local/mysql
[client]
socket=/var/lib/mysql/mysql.sock
然而service mysql restart
後還是不會自動生成mysql.sock檔案,依舊報錯,不過這給了我啟發,難道自動生成的不一定在這?
使用find命令
找找
find / -name *mysql*sock*
果然,找到了一個很像的檔案mysqld.sock
憑藉之前安裝mysql要解決中文亂碼問題的記憶,似乎看到過mysqld.sock
這傢伙。
檢視mysql的基本配置資訊
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
可以看到預設的socket對應 /var/run/mysqld/mysqld.sock
所以照這修改上面第一版的/etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
basedir=/usr
socket=/var/run/mysqld/mysqld.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3306
socket=/var/run/mysqld/mysqld.sock
重新連結mysql,大功告成!
相關文章
- Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock錯誤MySqlServer
- MySQL報錯'ERROR 2002 (HY000): Can't connect to local MySQL server through'MySqlErrorServer
- 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
- Can't connect to local MySQL server through socket '/tmp/mysql.sock'MySqlServer
- mysqldump: Got error: 2002: Can't connect to local MySQL server through.....MySqlGoErrorServer
- MySQL 5.5 關閉資料庫報錯"Can't connect to local MySQL server through socket"MySql資料庫Server
- ERROR 2002(HY000):Can't connect to local MySQL socket '/tmp/mysql.sock'ErrorMySql
- 更換mysql資料目錄後出現ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 的解決辦法MySqlErrorServer
- mysql 啟動報錯Can't connect to local MySQL server through socket '/data/mysql/mysql/mysql.sock'(111)MySqlServer
- 解決Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2) "MySqlServer
- ERROR 2002 (HY000): Cant connect to local MySQL server through socket的解決方法ErrorMySqlServer
- ERROR 2002 (HY000): Can't connect server socket /tmp/mysql.sockErrorServerMySql
- ERROR 2002 (HY000): Can't connect server socket /var/run/mysqld/mysqld.sockErrorServerMySql
- 連線MySQL錯誤:Can't connect to MySQL server (10060)MySqlServer
- error:'Can'tconnecttolocalMySQLserverthroughsocket'/var/lib/mysql/mysql.sock'(2)'ErrorMySqlServer
- 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
- MySQL 5.5 原始碼安裝報錯"[ERROR] Can't start server"MySql原始碼ErrorServer
- mysql [ERROR] Can't create IP socket: Permission deniedMySqlError
- Navicat連線centos裡mysql報錯Host is not allowed to connect to this MySQL serverCentOSMySqlServer
- Mysql報錯Fatal error:Can't open and lock privilege tablesMySqlError
- Navicat 連線 MySQL 失敗:2002-can‘t connect to server on localhost(10061)問題解決MySqlServerlocalhost
- mysql can't connect error about privilege----not root userMySqlError
- MySQL遠端連線ERROR 2003 (HY000) Cant connect to MySQL server on (10060)MySqlErrorServer
- MySQL5.6:mysql_secure_installation 報錯ERROR 2002 (HY000)MySqlError
- Can'tconnecttolocalMySQLserverthroughsocket'/var/lib/mysql/mysql.sock'(2)MySqlServer
- 異常:Can't connect to MySQL server (10060)MySqlServer
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- Mysql連線錯誤ERROR 2003 (HY000)MySqlError
- [ERROR] mysqld: Can‘t open shared library ‘/usr/local/mysql/lib/plugin/validate_password.so‘ (errno:ErrorMySqlPlugin
- DBeaver連線MySQ報錯
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- 【MySQL】ERROR 1005 (HY000): Can't create table' (errno: 150)MySqlError
- MySQL 5.7向表匯入資料包錯"ERROR 13 (HY000): Can't get stat of"MySqlError
- 虛擬機器NAT模式下連線mysql報錯:Host '192.168.30.1' is not allowed to connect to this MySQL server虛擬機模式MySqlServer
- MySQL報錯ERROR 2013 (HY000): Lost connection to MySQL server during queryMySqlErrorServer
- 【linux】Can't connect to MySQL server on 'XXX' (13)問題解決方式LinuxMySqlServer