ERROR 2002 (HY000): Can’t connect to local MySQL

來源:互聯網
上載者:User

標籤:ERROR2002(HY000

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 through socket ‘/var/run/mysqld/mysqld.sock’ (2)

方案1.
1.#ps -A|grep mysql
顯示類似:
1829 ? 00:00:00 mysqld_safe
1876 ? 00:00:31 mysqld
2.#kill -9 1829
3.#kill -9 1876
4.#/etc/init.d/mysql restart
5.#mysql -u root -p

方案2
先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已經啟動.
另外看看是不是許可權問題.
————————————————————————————
[[email protected] beinan]#chown -R mysql:mysql /var/lib/mysql
[[email protected] beinan]# /etc/init.d/mysqld start
啟動 MySQL: [ 確定 ]
[[email protected] lib]# mysqladmin -uroot password ‘123456’
[[email protected] lib]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 3 to server version: 4.1.11

Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the buffe

方案4

 /var/lib/mysql 所有檔案許可權 改成mysql.mysql

方案5
摘要:解決不能通過mysql .sock串連MySQL問題 這個問題主要提示是,不能通過 ‘/tmp/mysql .sock’連到伺服器,而php標準配置正是用過’/tmp/mysql .sock’,但是一些mysql 安裝方法 將 mysql .sock放在/var/lib/mysql .sock或者其他的什麼地方,你可以通過修改/etc/my.cnf檔案來修正它,開啟檔案,可以看到如下的東東:
  [mysql d]
  socket=/var/lib/mysql .sock
  改一下就好了,但也會引起其他的問題,如mysql 程式連不上了,再加一點:
  [mysql ]
  socket=/tmp/mysql .sock
  或者還可以通過修改php.ini中的配置來使php用其他的mysql .sock來連,這個大家自己去找找
  
  或者用這樣的方法:
  ln -s /var/lib/mysql /mysql .sock /tmp/mysql .sock
成功了,就是這樣ln -s /var/lib/mysql /mysql .sock /tmp/mysql .sock

ERROR 2002 (HY000): Can’t connect to local MySQL

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.