SQL connections

I am using:

if ($db = mysql_connect (‘mysql.mikemck.com’ ))
(passwords and user removed for security.)

in a PHP script. It is returning an error however:

Warning: mysql_connect() [function.mysql-connect]: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

What does this mean, and how can I get around it?

It could really mean any number of things…

First, and I assume you’ve created a database already via the control panel, have you given permissions to the user trying to access your mysql database?
I’m also not sure you can connect to just the mysql server, without specifying which database it is you wish to use.
Considering you can specify which host(s) are allowed to connect and such anyways, it would only make sense. Though I’ve never tried to get a list of all my databases with one of my limited accounts, so it might be something worth looking into :wink:

Other than that, the only thing I can really think of is that your database server might have been down at the time.
It does happen occasionally, though very infrequently in my experiences thus far.

I can connect to the server via SSH so it wasn’t/isn’t down. Connecting to a database is a separate step, and I would need to connect to the SQL server first in order to do that. But there is a database there.

The MySQL database server isn’t on the server you connect to through SSH. It’s located elsewhere on DreamHost’s network, on it’s own server. So whether or not you could ssh in is irrelevant.

I meant that in the sense, that by connecting through ssh I can then run do a myql -u… command to access SQL that way. In any case, I figured out the problem. Due to a duplicate file I was editing one, and uploading another, which had not been givent the correct info.

Ahhh, alright. Well at least you got it sorted out then :slight_smile:

Yeah, thanks for the help.