I'm trying to set up WordPress. I have Apache and MySQL running and the accounts and databases are set up. I try to establish a simple connection:
<?php $conn = mysql_connect('localhost', 'USER', 'PASSWORD'); if(!$conn) { echo 'Error: ' . mysql_errno() . ' - ' . mysql_error(); } ?>
I always get this:
Error: 2002 - No such file or Table of contents
What file or directory is it talking about?
I'm using OS X Snow Leopard, using the built-in Apache. I installed MySQL using x86_64 dmg.
Update: I discovered that the socket is located at /tmp/mysql.sock, so in php.ini I replaced all occurrences of the wrong path with that.
I had a similar problem and was able to resolve my mysql issue by using
127.0.0.1
instead oflocalhost
.This probably means something is wrong with my hosting setup, but I need this quick fix right now.
If you are using Linux: The path to the mysql.sock file is wrong. This is usually because you are using (LAMPP) XAMPP and it is not in /tmp/mysql.sock
Open the php.ini file and find this line:
Then do it