I keep getting this error, and was wondering if anyone knows how to fix it? mysql_pconnect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Thanks to anyone who can help.
local or remote? You're obviously not connection properly to the database, check you database name, password and location try using mysql_connect()
It may be that your server isn't listeing on the default port. Run this command and see if anything comes back: netstat -an | grep 3306 If there's a server listening on this port (or whatever other port you chose for MySQL), it may be that your server is configured not to accept connections on the loopback address. Try connecting to your actual IP address using the mysql utility (replace values in brackets with actual values) mysql -u [my-user-name] -p -h [my-ip-address] and check your system databases: select host, db, user from db; select host, user from user; select host, db from host; See if localhost is listed in any of these results (it may also be a wildcard). J.D.
Thanks for all your response, appreciate it. It's local, by the way. J.D. I don't think I can run a command on a shared host, can I? I'm sure I sound dumb, I have no knowledge what so ever on MySQL. My next dumb question would be, which MySQL utility? I think I'm going to struggle here. Thanks
Sounds like an issue your host should sort out, IMHO (unless you're trying to do something funky with your code). I'd open a ticket with them.
There's a utility called mysql. You need access to the command line to be able to use this utility. If you run mysql as I quoted, you will connect as the specified user to the machine identified by the specified address. Try 127.0.0.1 and the actual IP address of your machine. If you can connect using one of these addresses, you can use the same address in your PHP code. J.D.
I agree with davedx, this happened to me countless times on shared hosting. One trouble ticket and problem solved in a few minutes.
What I would try first, though, is to try connecting using TCP/IP sockets. For example: mysql_connect("localhost", "root", "root"); PHP: It seems that you used Unix sockets to connect (i.e. /tmp/mysql.sock). This file may be located elsewhere, depending on how your hosting company set your MySQL. If you want to use Unix sockets, you need to ask your hosting company where the socket file is located. If you have access to the command line, you can try runnin this command to figure it out (you may need to find where mysqld is located first): mysqld --help --verbose | grep "^socket" J.D.
Thanks guys, I appreciate you all taking the time to respond. I have opened a trouble ticket with my web host, as I don't have access to make changes because I'm on a shared host. I think you are right J.D. I have read that some hosts have MySQL set up in different locations. Thanks for your feedback, I now have more understanding on this issue.
Sorry for the slow reply. It may seem like a stupid mistake but the mysql host in the common.php file should have been mysql.websitesoure.net NOT localhost. According to the particular read me file this wasn't something that was normally to be altered. I suppose I should have checked this, especially as I'm on a shared host. Thanks for your help.
The good thing about share hosting is that you can open a ticket and have someone work it out for you. Get a dedicated server and you are on your own... I had to hire a server admin to keep an eye on the server and fix any potential problems.
I ran across this same problem with a recent webhosting account I got with GoDaddy.com. The MySQL database was located on a different server than the shared web server so localhost wouldn't work in the connection string. You had to specify the name of the server that had the database. The host name of the database server should be displayed in the MySQL settings in whichever particular server/web hosting/database management utility your hosting company uses.