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.


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


From the PHP Documentation for mysql_connect:

If you want to use TCP/IP, use "" 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy