Dịch vụ lưu trữ Web và Cổ điển Trợ giúp

What do I do when I receive MySQL local connect error?

Error Message:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /home/content/u/s/e/username/html/file.php on line 2

Cause:

This is caused by your script trying to connect to 'localhost' as the MySQL server.  The error displays the exact line that needs to be altered (in this case, it is on /file.php line 2).

Resolution:

To resolve this error, change your database connection string to use the correct server name. This can be found in the MySQL section of your Hosting Control Panel.

Incorrect Example:

mysql_connect("localhost", "username, "password");

Correct Example:

mysql_connect("mysql12.secureserver.net", "username", "password");

For more information see Choosing a Host Name for Your SQL Database.

Bài này có hữu ích không?
Thanks for your feedback. To speak with a customer service representative, please use the support phone number or chat option above.
Rất vui vì chúng tôi đã giúp được bạn! Chúng tôi có thể làm gì thêm cho bạn?
Rất tiếc về điều đó. Tell us what was confusing or why the solution didn’t solve your problem.