每次登錄mysql都報:無能通過 '/var/lib/mysql/mysql.sock' 登錄
帖子
重慶思庄Oracle論壇
?
首頁
?
資料庫
?
MySQL
?
每次登錄mysql都報:無能通過 /var/lib/mysql/mysql.so ...
最新公告:帳號無法登錄解決辦法,必看!(2015-11-02)熱烈祝賀Oracle西部用戶組技術盛會取得圓滿(2015-11-02)論壇粘貼上傳圖片快捷方式~(2015-11-02)
返回列表
發新帖
查看: 741|回復: 0
列印 上一主題 下一主題
每次登錄mysql都報:無能通過 /var/lib/mysql/mysql.sock 登錄 [複製鏈接]
鄭全
電梯直達
跳轉到指定樓層
樓主
發表於 2015-4-22 10:15:06 | 只看該作者 回帖獎勵
問題如下:
[root@sztech1 ~]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Cant connect to local MySQL server through socket /var/lib/mysql/mysql.sock (2)
分析:
查看mysql是否啟動
[root@sztech1 ~]# ps -ef|grep mysql
root 1620 1 0 10:00 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/mysqld.pid
mysql 2072 1620 0 10:00 ? 00:00:04 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/sztech1.err --pid-file=/usr/local/mysql/mysqld.pid --socket=/usr/local/mysql/mysql.sock
root 2422 2378 0 10:09 pts/0 00:00:00 grep mysql
mysql使用 socket=/usr/local/mysql/mysql.sock 啟動的
查看 /var/lib/mysql/mysql.sock 不存在,
查看 /usr/local/mysql/mysql.sock ,存在
試圖在後面加上/usr/local/mysql/mysql.sock 登錄
[root@sztech1 ~]# mysql -uroot -p -S /usr/local/mysql/mysql.sock ,又可以正常登錄
說明一下,我的mysql是源碼編譯的,如果使用rpm包安裝,默認會安裝到 /var/lib/mysql下面去,
解決:
既然在後面加上 -S /usr/local/mysql/mysql.sock 可以登錄,那就在參數文件中,加上該行即可,具體修改 /etc/my.cnf
加上
[mysql]
socket=/usr/local/mysql/mysql.sock
再次登錄,不在報錯:
[root@sztech1 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.6.23-log Source distribution
Copyright (c) 2000, 2013, 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>
推薦閱讀: