Hello
I have a website where i have used php and mysql,till now both php and mysql were located in same server and my site was working fine but recently we have shifted Mysql to a different server.
In the php code we have changed the server name with the new server name.but when we try to open the page we are getting error
THE ERROR IS
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/web/XXXXX/STONEDIVER_PHP_LIBRARY/source/shared/database.php on line 38
Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
The code before migration of Mysql was
$server = "localhost";
$dbname = "database";
$user = "username"; //Allowed for the ip
$password = "password";
$link = mysql_connect($server,$user,$password) or die(mysql_error());
mysql_select_db($dbname);
The code after migrating Mysql is
$server = "serverip/servername";
$dbname = "database";
$user = "username"; //Allowed for the ip
$password = "password";
$link = mysql_connect($server,$user,$password) or die(mysql_error());
mysql_select_db($dbname);
I have tried using both server IP and server name...
Please help me out in solving this problem...
THANKS IN ADVANCE
Connecting Mysql database located in different server in php
Moderator: General Moderators
Re: Connecting Mysql database located in different server in php
http://dev.mysql.com/doc/refman/5.0/en/ ... erver.html
Check the right port (3306) is open on the firewall if there is one.
Check the right port (3306) is open on the firewall if there is one.
Re: Connecting Mysql database located in different server in php
Thank you onion2k
port is open and there is no problem with firewall.
port is open and there is no problem with firewall.
Re: Connecting Mysql database located in different server in php
After you updated the $server with your new server, are you still getting that exact error? I'm curious why it is trying to connect to a local server if you have updated the $server to your new host.Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/web/XXXXX/STONEDIVER_PHP_LIBRARY/source/shared/database.php on line 38
Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Re: Connecting Mysql database located in different server in php
Thank you guys the link from onion2k was of great help i am able to solve my issue..thanks once again