Php fails to connect to mysql, but the normal solution through mysql Command

Source: Internet
Author: User
Tags php website
Fault status: the php website fails to connect to mysql. However, you can use the mysql command in the command line to log on and operate normally. Solution: log on to mysql under the command line and run the following command: showvariableslikesocket. After the command is executed, the following echo will be obtained: Variable_namenbsp; nbsp; Valuesocketnbsp; nbsp; nb

Fault status: the php website fails to connect to mysql. However, you can use the mysql command in the command line to log on and operate normally. Solution: log on to mysql under the command line and run the following command: showvariableslikesocket. After the command is executed, the following echo will be obtained: Variable_namenbsp; nbsp; Value socketnbsp; nbsp; nb

Fault status: the php website fails to connect to mysql. However, you can use the mysql command in the command line to log on and operate normally.

Solution:

Log on to mysql under the command line and execute the following command:

Showvariableslikesocket;

After the command is executed, the echo is similar to the following:

Variable_namenbsp; nbsp; Value
Socketnbsp; nbsp;Homemysqldatamysqlsock

2. Edit phpini and find the mysqldefault_socket configuration item. The default value is generally a null value (use the sock path set during Mysql editing). Set the value of this item to the above echo.Homemysqldatamysqlsock:

; DefaultsocketnameforlocalMySQLconnectsnbsp; Ifemptyusesthebuiltin
; MySQLdefaults
Mysqldefault_socket = homemysqldatamysqlsock

3. Restart php.

Original article address: php fails to connect to mysql but the solution is normal through mysql Command. Thank you for sharing it with me.

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.