Can't connect to local MySQL server through socket '/tmp/mysql.sock' (46) - mysql
This is a discussion on Can't connect to local MySQL server through socket '/tmp/mysql.sock' (46) - mysql ; Hi, Our hosting company is Yahoo! and we have a MySQL 4.1.6 database. phpMyAdmin 2.6.3 is installed and I can manipulate the db fine through that. However, when I try and connect through a PHP file using $db_hostname = "localhost"; ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| Our hosting company is Yahoo! and we have a MySQL 4.1.6 database. phpMyAdmin 2.6.3 is installed and I can manipulate the db fine through that. However, when I try and connect through a PHP file using $db_hostname = "localhost"; $db_socket = ""; $mysql_host = $db_hostname; if (!empty($db_socket)) $mysql_host .= ":$db_socket"; $db_name = "mydb"; $db_user = "myuser"; $db_password = "mypass"; // Connect mysql_connect($mysql_host, $db_user, $db_password) or die("Can't connect to MySQL: '" . mysql_error() . "'"); I get the above error. How can I fix this? Thanks, - Dave |
|
#2
| |||
| |||
| laredotornado@zipmail.com wrote: > Hi, > > Our hosting company is Yahoo! and we have a MySQL 4.1.6 database. > phpMyAdmin 2.6.3 is installed and I can manipulate the db fine through > that. However, when I try and connect through a PHP file using > > $db_hostname = "localhost"; > $db_socket = ""; > > $mysql_host = $db_hostname; > if (!empty($db_socket)) > $mysql_host .= ":$db_socket"; > $db_name = "mydb"; > $db_user = "myuser"; > $db_password = "mypass"; > > // Connect > mysql_connect($mysql_host, $db_user, $db_password) or die("Can't > connect to MySQL: '" . mysql_error() . "'"); > > I get the above error. How can I fix this? > > Thanks, - Dave > First of all, you shouldn't need the socket. Just use 'localhost'. Does this work? $result = mysql_connect('localhost', 'myuser', 'mypass'); if (!$result) echo "Unable to connect: " . mysql_error(); else { /// do stuff (die() is not good to use in a production system - handle your errors more gracefully!). -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
#3
| |||
| |||
|
On Thu, 23 Aug 2007 08:48:04 -0700, laredotornado@zipmail.com wrote: > Hi, > > Our hosting company is Yahoo! and we have a MySQL 4.1.6 database. > phpMyAdmin 2.6.3 is installed and I can manipulate the db fine through > that. However, when I try and connect through a PHP file using > > $db_hostname = "localhost"; > $db_socket = ""; > > $mysql_host = $db_hostname; > if (!empty($db_socket)) > $mysql_host .= ":$db_socket"; > $db_name = "mydb"; > $db_user = "myuser"; > $db_password = "mypass"; > > // Connect > mysql_connect($mysql_host, $db_user, $db_password) or die("Can't > connect to MySQL: '" . mysql_error() . "'"); > > I get the above error. How can I fix this? Which above error? I see code, but no error. What does the mysql_error() function actually spit out? -- 6. I will not gloat over my enemies' predicament before killing them. --Peter Anspach's list of things to do as an Evil Overlord |
|
#4
| |||
| |||
|
Peter H. Coffin wrote: > On Thu, 23 Aug 2007 08:48:04 -0700, laredotornado@zipmail.com wrote: >> Hi, >> >> Our hosting company is Yahoo! and we have a MySQL 4.1.6 database. >> phpMyAdmin 2.6.3 is installed and I can manipulate the db fine through >> that. However, when I try and connect through a PHP file using >> >> $db_hostname = "localhost"; >> $db_socket = ""; >> >> $mysql_host = $db_hostname; >> if (!empty($db_socket)) >> $mysql_host .= ":$db_socket"; >> $db_name = "mydb"; >> $db_user = "myuser"; >> $db_password = "mypass"; >> >> // Connect >> mysql_connect($mysql_host, $db_user, $db_password) or die("Can't >> connect to MySQL: '" . mysql_error() . "'"); >> >> I get the above error. How can I fix this? > > Which above error? I see code, but no error. What does the mysql_error() > function actually spit out? > Peter, See the subject line... -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
#5
| |||
| |||
|
"laredotornado@zipmail.com" news:1187884084.643085.40620@l22g2000prc.googlegro ups.com: > Hi, > > Our hosting company is Yahoo! and we have a MySQL 4.1.6 database. > phpMyAdmin 2.6.3 is installed and I can manipulate the db fine through > that. However, when I try and connect through a PHP file using > > $db_hostname = "localhost"; > $db_socket = ""; > > $mysql_host = $db_hostname; > if (!empty($db_socket)) > $mysql_host .= ":$db_socket"; > $db_name = "mydb"; > $db_user = "myuser"; > $db_password = "mypass"; > > // Connect > mysql_connect($mysql_host, $db_user, $db_password) or die("Can't > connect to MySQL: '" . mysql_error() . "'"); > > I get the above error. How can I fix this? I'm pretty sure Yahoo has a tech support page on how to connect to databases... well in fact i'm positive http://help.yahoo.com/help/us/geo/mysql/mysql-11.html and in general, http://help.yahoo.com/help/us/geo/mysql/ |
|
#6
| |||
| |||
|
databasehost="localhost" tochange databasehost="mysql" that is enough in your config file you have to use mysql instead of localhost. |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| Display Modes | |
| |
All times are GMT -4. The time now is 08:02 AM.




Linear Mode