I have MySQL server running on my local computer. I am trying to connect to it through PHP from my website host. I get the following error:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).
Here is the php I am running with the userid and password wiped out for security:
if ($dbc = @mysql_connect('localhost', 'userid', 'password')) {
print '<p>Successfully connected to MySQL!</p>';
// Try to create the database:
if (@mysql_query('CREATE DATABASE myblog',$dbc)) {
print '<p>The database has been created!</p>';
} else { // Could not create it.
print '<p style="color: red;">Could not create the database because:<br />' . mysql_error() . '.</p>';
}
// Try to select the database:
if ($x == @mysql_select_db('myblog,$dbc')) {
print '<p>The database has been selected.</p>';
} else {
print '<p style="color: red;">Could not select the database because:<br />' . mysql_error() . '.</p>';
}
mysql_close(); // Close the connection.
} else {
print '<p style="color: red;">Could not connect to MySQL:<br />' . mysql_error() . '.</p>';
Can someone help me with this connection?