綠色資源網(wǎng):您身邊最放心的安全下載站! 最新軟件|熱門(mén)排行|軟件分類(lèi)|軟件專(zhuān)題|論壇轉(zhuǎn)帖|廠商大全

綠色資源網(wǎng)

技術(shù)教程
您的位置:首頁(yè)數(shù)據(jù)庫(kù)類(lèi)MySQL → 解決不能通過(guò)mysql.sock連接MySQL問(wèn)題的辦法

解決不能通過(guò)mysql.sock連接MySQL問(wèn)題的辦法

我要評(píng)論 2011/05/17 14:29:35 來(lái)源:綠色資源網(wǎng) 編輯:downcc.com [ ] 評(píng)論:0 點(diǎn)擊:386次

摘要:解決不能通過(guò)mysql.sock連接MySQL問(wèn)題 這個(gè)問(wèn)題主要提示是,不能通過(guò) '/tmp/mysql.sock'連到服務(wù)器,而php標(biāo)準(zhǔn)配置正是用過(guò)'/tmp/mysql.sock',但是一些mysql安裝方法將 mysql.sock放在/var/lib/mysql.sock或者其他的什么地方,你可以通過(guò)修改/etc/my.cnf文件來(lái)修正它,打開(kāi)文件,可以看到如下的東東:

   [mysqld]
  socket=/var/lib/mysql.sock
  改一下就好了,但也會(huì)引起其他的問(wèn)題,如mysql程序連不上了,再加一點(diǎn):
  [mysql]
  socket=/tmp/mysql.sock
  或者還可以通過(guò)修改php.ini中的配置來(lái)使php用其他的mysql.sock來(lái)連,這個(gè)大家自己去找找
  
  或者用這樣的方法:
  ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
  
  還有:
  phpmyadmin的說(shuō)明書(shū)有說(shuō)
  The error message "Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)..." is displayed. What can I do?
  
  For RedHat users, Harald Legner suggests this on the mailing list:
  
  On my RedHat-Box the socket of mysql is /var/lib/mysql/mysql.sock. In your php.ini you will find a line
  mysql.default_socket = /tmp/mysql.sock
  change it to
  mysql.default_socket = /var/lib/mysql/mysql.sock

  Then restart apache and it will work.
  
  Here is a fix suggested by Brad Ummer in the phpwizard forum:
  
  First, you need to determine what socket is being used by MySQL.
  To do this, telnet to your server and go to the MySQL bin directory. In this directory there should be a file named mysqladmin. Type ./mysqladmin variables, and this should give you a bunch of info about your MySQL server, including the socket (/tmp/mysql.sock, for example).
  Then, you need to tell PHP to use this socket.
  Assuming you are using PHP 3.0.10 or better, you can specify the socket to use when you open the connection. To do this in phpMyAdmin, you need to complete the socket information in the config.inc.php

3.
  For example: $cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock'; (T113)

關(guān)鍵詞:mysql.sock,MySQL

閱讀本文后您有什么感想? 已有 人給出評(píng)價(jià)!

  • 0 歡迎喜歡
  • 0 白癡
  • 0 拜托
  • 0 哇
  • 0 加油
  • 0 鄙視