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 啟動報錯Can't connect to local MySQL server through socket '/data/mysql/mysql/mysql.sock'(111)MySqlServer
- Navicat 連線 MySQL 失敗:2002-can‘t connect to server on localhost(10061)問題解決MySqlServerlocalhost
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- docker phpmyadmin 連線宿主mysql資料庫報錯:mysqli::real_connect(): (HY000/2002): Connection refusedDockerPHPMySql資料庫
- Navicat連線centos裡mysql報錯Host is not allowed to connect to this MySQL serverCentOSMySqlServer
- [ERROR] mysqld: Can‘t open shared library ‘/usr/local/mysql/lib/plugin/validate_password.so‘ (errno:ErrorMySqlPlugin
- Mysql連線錯誤ERROR 2003 (HY000)MySqlError
- MySQL報錯ERROR 2013 (HY000): Lost connection to MySQL server during queryMySqlErrorServer
- Can't Connect to MySQL Server on IP Address (10061) 錯誤的解決方案MySqlServer
- 虛擬機器NAT模式下連線mysql報錯:Host '192.168.30.1' is not allowed to connect to this MySQL server虛擬機模式MySqlServer
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- ERROR 1290 (HY000): The MySQL server is running withErrorMySqlServer
- docker mysql mysqld: Error on realpath() on ‘/var/lib/mysql-files‘ No such file or directoryDockerMySqlError
- 使用雲伺服器配置MariaDB環境,Navicat遠端連線一直出錯誤程式碼 "2002 - Can't connect to server on '' (10060)"伺服器Server
- DBeaver連線MySQ報錯
- 連線mysql報錯lost connect to sever during query解決MySql
- mysql匯入sql檔案報錯 ERROR 2013 2006 2002MySqlError
- MYSQL報1022錯誤:Can't write;duplicate key in table '.....'MySql
- 解決MySql報錯:1130 - Host ‘xxx‘ is not allowed to connect to this MySQL server的方法MySqlServer
- MySQL 報錯 ERROR 1290 (HY000): running with the --secure-file-privMySqlError
- Error:Can't connect to SOCKS proxy:Connection refused (Connection refused)Error
- Linux:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannLinuxErrorMySqlServer
- Mac電腦下使用Socket報錯socket丟擲Can’t assign requested address解決Mac
- ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization paErrorMySqlServer
- 【MySQL】ERROR 1290 (HY000): --secure-file-priv--匯出報錯MySqlError
- Error!: SQLSTATE[HY000] [2002] Connection refusedErrorSQL
- mysql 5.6.25報錯ERROR 1372 (HY000): Password hash 的一點思考MySqlError
- ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables optErrorMySqlServer
- MySQL 5.7 建立使用者報錯 ERROR 1805 (HY000): Column count of mysql.user is wrongMySqlError
- Centos7-mysql執行報錯ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement.CentOSMySqlError
- Linux報錯:Could not get lock /var/lib/dpkg/lock-frontendLinux
- MySQL-1130-host ... is not allowed to connect to this MySql serverMySqlServer
- 連線mysql時提示is not allowed to connect不允許連線MySql
- MySQL建立使用者報錯 ERROR 1396 (HY000): Operation CREATE USER failed for 'afei'@'%'MySqlErrorAI
- GTID複製報錯處理:Last_Error: Error 'Can't drop database 'test';ASTErrorDatabase
- Host 'localhost' is not allowed to connect to this MySQL serverlocalhostMySqlServer
- “Host ‘xxxx‘ is not allowed to connect to this MySQL server“MySqlServer