Jump to content

Can't connect ... '/var/lib/mysql/mysql.sock


turpentyne

Recommended Posts

I'm trying to add a new section to somebody's existing site. I need to connect to the database, and I'm not sure what to do with the error I got:

 

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/m/c/m/mcmfamily/html/builder-test-code/dbc.php on line 10

 

 

Here's what I'm using as my connection:

<?php 



function dbconn() {
if(!include_once('../filepath/dbc_include.php')) {
die('Error include file...');
}

if(!$link = mysql_connect($db['hostname'],$db['username'],$db['password'])) {
die('Error connecting...');
}

if(!mysql_select_db($db)) {
die('Error selecting...');
}

return $link;


echo @mysql_ping() ? 'true' : 'false';

}
$link = dbconn(); 

?>

Link to comment
https://forums.phpfreaks.com/topic/266245-cant-connect-varlibmysqlmysqlsock/
Share on other sites

Is this on a local machine, or on a web host?  This is basically saying that the server cannot find the mysql socket(file, not port).

 

Either:

A. The socket file is in another location. ie /tmp/mysql.socket

B. The MySQL installation is hosed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.