ERROR 2002 (HY000): Can't connect to local MySQL server through socket
在安裝好了MySQL之後,使用了新的配置檔案後,MySQL伺服器可以成功啟動,但在登陸的時候出現了ERROR 2002 (HY000): Can’t connect to local MySQL server through socket,即無法通過socket連線到mysql伺服器,同時提供了socket檔案的位置。下面是這個問題的描述與解決辦法。
1、故障現象
[[email protected] mysqldata]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/data/mysqldata/mysql.sock’ (111)
故障環境
[[email protected] mysqldata]# more /etc/issue
CentOS release 5.9 (Final)
Kernel \r on an \m
2、故障分析
檢視mysql例項的狀態
[[email protected] mysqldata]# netstat -ntlp | grep 3306
tcp 0 0 :::3306 :::* LISTEN 13001/mysqld
檢視my.cnf關於socket的配置
[[email protected] mysqldata]# more /etc/my.cnf |grep sock
socket = /tmp/mysql.sock
由上可知my.cnf中定義的為/tmp目錄下,而錯誤提示為/data/mysqldata/目錄下
也就是說mysqld已經聲稱了正確的sock檔案,但客戶端連線還是從初始目錄去找sock檔案
下面檢視後臺日誌,有個ERROR,是關於滿查詢日誌的,是由於目錄不存在而產生的錯誤,與當前故障無關
[[email protected] mysqldata]# more SZDB.err
…………
2014-10-11 13:17:21 13001 [Note] InnoDB: 5.6.12 started; log sequence number 1625997
/app/soft/mysql/bin/mysqld: File ‘/log/mysql_logs/slowquery.log’ not found (Errcode: 2 - No such file or directory)
2014-10-11 13:17:21 13001 [ERROR] Could not use /log/mysql_logs/slowquery.log for logging (error 2). Turning logging off for the who
le duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
2014-10-11 13:17:21 13001 [Note] Server hostname (bind-address): ‘*’; port: 3306
2014-10-11 13:17:21 13001 [Note] IPv6 is available.
2014-10-11 13:17:21 13001 [Note] - ‘::’ resolves to ‘::’;
2014-10-11 13:17:21 13001 [Note] Server socket created on IP: ‘::’.
2014-10-11 13:17:21 13001 [Note] Event Scheduler: Loaded 0 events
2014-10-11 13:17:21 13001 [Note] /app/soft/mysql/bin/mysqld: ready for connections.
Version: ‘5.6.12-log’ socket: ‘/tmp/mysql.sock’ port: 3306 Source distribution
3、解決故障
a、通過配置my.cnf mysql選項socket檔案位置解決
先停止mysql伺服器
[[email protected] mysqldata]# service mysqld stop
Shutting down MySQL.[ OK ]
修改my.cnf,如下
[[email protected] mysqldata]# vi /etc/my.cnf
[mysql]
no-auto-rehash
socket = /tmp/mysql.sock #新增該行
重啟mysql伺服器
[[email protected] mysqldata]# service mysqld start
Starting MySQL..[ OK ]
再次連線正常
[[email protected] mysqldata]# mysql -uroot -p
Enter password:
mysql> show variables like ‘version’;
+—————+————+
| Variable_name | Value |
+—————+————+
| version | 5.6.12-log |
+—————+————+
b、為socket檔案建立連結方式
[[email protected] mysqldata]# ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock
ln: creating symbolic link /data/mysqldata/mysql.sock' to
/tmp/mysql.sock’: File exists
[[email protected] mysqldata]# rm mysql.sock #上面提示檔案存在,所以刪除之前的mysql.sock檔案
[[email protected] mysqldata]# ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock
[[email protected] mysqldata]# ls -hltr mysql.sock
lrwxrwxrwx 1 root root 15 Oct 11 14:00 mysql.sock -> /tmp/mysql.sock
[[email protected] mysqldata]# mysql -uroot -p
Enter password:
mysql> show variables like ‘socket’;
+—————+—————–+
| Variable_name | Value |
+—————+—————–+
| socket | /tmp/mysql.sock |
+—————+—————–+
相關推薦
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 啟動不了
nag could ice etc ket nbsp call cti connect ps -A | grep -i mysql kill 列出來的進程 service mysql start 我的問題就解決了 -----------------------------
linux 系統中系統關機後,mysql啟動失敗報錯:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '
自己在阿里雲伺服器上安裝好執行環境後,mysql都是正常使用的,昨天強制關閉伺服器後,重新啟動伺服器,發現數據庫無法啟動報錯:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/va
MySQL 報錯:ERROR 2002 (HY000): Can't connect to local MySQL server through socket
一、錯誤現場還原: 下面我們通過三種方式來連線,然後觀察提示的錯誤資訊: 1、直接使用“mysql”命令,不帶主機名引數; 2、使用帶了主機名“localhost”引數的“mysql -h localhost”命令; 3、使用帶了主機名“127.0.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysqld.sock'
先檢視 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已經啟動. 另外看看是不是許可權問題. ———————————————————————————— [[email protected] beinan]#chown -R mysql:mysql /var
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
1:下載 [[email protected] /]# tar -xzvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ 1 3修改檔案 [[email protecte
解決mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket錯誤的方法
ps -A | grep -i mysql kill 列出來的程序 service mysql start 我的問題就解決了 Fedora8啟動mysql 報錯: ERROR 2002 (HY000): Can’t connect to local MySQL
MySql 報錯ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
MySql 報錯ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) 這個錯是連結時報的錯,要連結必須啟動。修復的時候首先要啟動m
mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解決方法:原因:mysql目錄沒有許可權 方法:執行 sudo chown -R mysql:mysql /usr/local/var/mysql 給了許可權之後重啟 sudo mysql.ser
Linux上mysql登陸錯誤解決辦法ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' 解決方法:1:首先確認你在root許可權下 [[email p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (
某一次我可能沒有正常關閉Mysql就直接讓機器關機了,造成了MySQL下次都打不來了。 先檢視程序 ps -A | grep -i mysql 如果Mysql程序開啟了 就把這個程序kill -9 ,然後再啟動試試。 但我的mysql程序就是沒有啟動起來
MySQL ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
在solaris 和 ubuntu下啟動Mysql, 都提示了這樣的錯誤 在網上搜索了許多解決方案之後,做如下總結: 1、mysql 沒有啟動,或者說是無法啟動,則之後執行Mysql的時候會提示這個錯誤。 而啟動mysql的時候在/etc/init.d目錄下啟動,有
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock
問題描述 今天阿里雲伺服器安裝mysql的收,遇到了一個很熟悉的問題 輸入 #mysql -u root -p ERROR 2002 (HY000): Can't connect to local MySQL server through sock
Mysql資料庫連線,錯誤提示ERROR 2002 (HY000) Can't connect to local MySQL server through socket xxx' (2)
一、問題描述1、連線mysql資料庫時,提示錯誤:ERROR 2002 (HY000) Can't connect to local MySQL server through socket xxx' (
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
今天在linux裡安裝mysql,執行時遇到這樣的錯誤 ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ 上網
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock’(2) 是一個比較常見的資料庫報錯,而昨天我們的伺服器也報了這個錯誤,所有服務全掛,而且
centos下mysql問題記錄--ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/
一、關於雲主機的mysql最近一次雲主機的伺服器由於被攻擊便打算重灌一邊mysql,徹底刪除相關檔案後重新安裝,沒想到怎麼裝都會出問題。再啟動的時候總是出現ERROR 2002 (HY000): Can’t connect to local MySQL server thro
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
今天伺服器遇到了一個很熟悉的問題 輸入 #mysql -u root -p ERROR 2002 (HY000):Can't connect to local MySQL server 隨即上網找尋答案 根據大家提供的方法我逐一嘗試 方案1. 1.#ps -A|grep mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
在安裝好了MySQL之後,使用了新的配置檔案後,MySQL伺服器可以成功啟動,但在登陸的時候出現了ERROR 2002 (HY000): Can’t connect to local MySQL server through socket,即無法通過socket
CentOS下面ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
文章轉自:https://www.cnblogs.com/Lam7/p/6090975.html有時候,當我們使用“mysql”、“mysqladmin”、“mysqldump”等命令管理資料庫時,伺服器丟擲類似如下錯誤:一、錯誤現場還原:下面我們通過三種方式來連線,然後觀察提示的錯誤資訊:1、直接使用“my
記一次 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock’(2) 排錯流程
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock’(2) 是一個比