2

at first sorry for my english, i've a important question to resolve. I'm trying to connect to my dreamhost's database but it's returninng the following error:

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I've contacted Dreamhost support and they told me that it looks like the error was the result of using a newly created database hostname.

I see that the hostname is now working properly

Now, I have a php class to connect to my database. this is my command to connect:

$data = new MysqlClass('mysql.test.masterweblab.com','user','pass','data_name');

This works on my localhost. Anyone have a solution?

j0k
  • 22,600
  • 28
  • 79
  • 90
Ramboz89
  • 29
  • 4
  • 1
    if *"This works on my localhost"* then what is your problem? – Marcin Orlowski Nov 26 '12 at 00:45
  • If you're getting an error message that says it's trying to connect to `/var/run/mysqld/mysqld.sock`, it doesn't look like your hostname in your class is being used. – whamma Nov 26 '12 at 08:34
  • @WebnetMobile.com sorry i was not clear. With "this work on my localhost" i mean, when i use this code on my MAMP server it work, then my code is right ex.`code`$data = new MysqlClass('localhost','localuser','localpass','local_database');`code` – Ramboz89 Nov 26 '12 at 09:14
  • @whamma thank's for reply. Now i try with another code and re-post – Ramboz89 Nov 26 '12 at 09:15
  • Your problem is using Dreamhost in the first place. Just look at how many outages they have: https://twitter.com/dhstatus/ Used to work for a startup that used them and had 6 hours of downtime a week. Those clowns have no idea how to operate a data center. – Peter Hanneman May 22 '13 at 19:53
  • @Ramboz89 I don't know how your class tries to connect to MySQL but it should not be trying to use `mysql.sock` as you're not connecting to a `localhost` but rather a remote host so I would start by posting your relevant connection code. – Prix Jun 15 '13 at 23:15

1 Answers1

0

maybe they are using a different version of php or mysql than on your localhost?

try connecting to it like this on a new page and see if this works.

$link = mysql_connect("mysql.test.masterweblab.com", "user", "pass");
mysql_select_db("data_name") or die(mysql_error());

if ($link){
    echo "it worked!";
}else{
    echo "Failed " . mysql_error() ;
}

mysql_close();

If that doesn't work try pinging the host from a command prompt in windows. Copy the ip address and try.

$link = mysql_connect("THE_IP_YOU_COPIED", "USER", "PASS");
mysql_select_db("data_name")or die(mysql_error());

if ($link){
    echo "it worked!"
}else{
    echo "Failed " . mysql_error() ;
}

mysql_close();

Let us know what that produces.

if you cant get the ip from pinging the domain there's your problem! Log into cpanel and get your sql servers ip from phpmyadmin.

Nazca
  • 112
  • 1
  • 7