Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I finished a web page in my computer and it was saved in my pen drive. Now I uploaded the files .html and .php to the server, and I exported the database of my pen drive and imported it on the web address using phpmyadmin. Seems like I'm having the following problem:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /home/t1g01/doador.php on line 40

The files in my pen drive are working fine. But not in the server. Can anyone help me please? When I explore the tables in the http://address.com/phpmyadmin/ there are normal, with data.

I read something in another topic about restarting the mysql by typing /etc/init.d/mysql restart or ln -s /var/lib/mysql/mysql.sock /tmp/ . If that's solve my problem, where am I supposed to type this ? I'm new at this server stuff.

line 40 is like mysql_connect(localhost,$username,$password); username and password are fine, should I rename the localhost ?

Sorry for any mistake in English, and thanks in advance for the attention.

share|improve this question

1 Answer 1

You can try 127.0.0.1 which will force using TCP instead of the socket.

mysql_connect('127.0.0.1',$username,$password);

From the PHP Documentation for mysql_connect:

If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as in your PHP configuration and leave the server field blank.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.