Home Guides Glossary

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.

Domain Registration

Pay less for website domain names. Register your own .com, .net or .org for as low as $10.18 per year. We have everything you need to get online with your new domain.

Website Builder

Build an amazing website in just under an hour with Website Builder. Take advantage of designs created just for your industry and then customize them to reflect your one-of-a-kind idea.

Website Security

Protect your website and keep customers safe. Your comprehensive Website Security solution. Get peace of mind by securing your websites.

cPanel Hosting

Everything needed to give your website the high-performance home it deserves.  Protect transactions and secure your customer's data with a SSL Certificate
Copyright © 2005 - 2024.  All rights reserved.  Privacy Policy