程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 關於MYSQL數據庫 >> 解決不能通過mysql.sock連接MySQL問題的辦法

解決不能通過mysql.sock連接MySQL問題的辦法

編輯:關於MYSQL數據庫

  這個問題主要提示是,不能通過'/tmp/MySQL.sock'連到服務器,而PHP標准配置正是用過'/tmp/mysql.sock',但是一些mysql安裝方法將mysql.sock放在/var/lib/MySQL.sock或者其他的什麼地方,你可以通過修改/etc/my.cnf文件來修正它,打開文件,可以看到如下的東東:

  [MySQLd]

  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

  還有:

  PHPmyadmin的說明書有說

  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.PHP3.

  For example: $cfg['Servers'][$i]['socket'] = '/tmp/MySQL.sock';

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved