熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> MySQL >> 正文

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

2013-11-23 20:55:50  來源: MySQL 

  這個問題主要提示是不能通過/tmp/mysqlsock連到服務器而php標准配置正是用過/tmp/mysqlsock但是一些mysql安裝方法將mysqlsock放在/var/lib/mysqlsock或者其他的什麼地方你可以通過修改/etc/f文件來修正它打開文件可以看到如下的東東
  [mysqld]
  socket=/var/lib/mysqlsock
  改一下就好了但也會引起其他的問題如mysql程序連不上了再加一點
  [mysql]
  socket=/tmp/mysqlsock
  或者還可以通過修改phpini中的配置來使php用其他的mysqlsock來連這個大家自己去找找
  
  或者用這樣的方法:
  ln s /var/lib/mysql/mysqlsock /tmp/mysqlsock
  
  還有:
  phpmyadmin的說明書有說
  The error message Warning: MySQL Connection Failed: Cant connect to local MySQL server through socket /tmp/mysqlsock () is displayed What can I do?
  
  For RedHat users Harald Legner suggests this on the mailing list:
  
  On my RedHatBox the socket of mysql is /var/lib/mysql/mysqlsock In your phpini you will find a line
  mysqldefault_socket = /tmp/mysqlsock
  change it to
  mysqldefault_socket = /var/lib/mysql/mysqlsock
  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/mysqlsock for example)
  Then you need to tell PHP to use this socket
  Assuming you are using PHP 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 configincphp
  For example: $cfg[Servers][$i][socket] = /tmp/mysqlsock;
From:http://tw.wingwit.com/Article/program/MySQL/201311/29312.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.