Solution to the problem of connecting to mysql through MySQL. sock _ MySQL

Source: Internet
Author: User
The main cause of this problem is that you cannot use tmpmysql. sock is connected to the server, and the standard php configuration is using tmpmysql. sock, but some mysql installation methods will be mysql. put sock in varlibmysql. sock or somewhere else, you can modify etcmy. the cnf file is used to modify the cnf file. when you open the file, you can see the following stuff: [the main prompt for mysql is that you cannot use '/tmp/mysql. the sock is connected to the server, and the php Standard configuration has been used '/tmp/mysql. sock, but some mysql installation methods will be mysql. put sock in/var/lib/mysql. sock or somewhere else, you can modify/etc/my. modify the cnf file and open the file. you can see the following:
[Mysqld]
Socket =/var/lib/mysql. sock
Just change it, but it will also cause other problems. for example, if the mysql program cannot be connected, add one more point:
[Mysql]
Socket =/tmp/mysql. sock
You can also modify the configuration in php. ini to connect php to another mysql. sock.
  
Or use the following method:
Ln-s/var/lib/mysql. sock/tmp/mysql. sock
  
Also:
Phpmyadmin instructions
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. sock. In your php. ini you will find a line
Mysql. default_socket =/tmp/mysql. sock
Change it
Mysql. default_socket =/var/lib/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 shocould be a file named mysqladmin. type. /mysqladmin variables, and this shoshould 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 ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.