Forum Moderators: coopster
Some time ago, we activated a subdomain in our main domain
www.maindomain.com and subdomain.mydomain.com
All php scripts worked as expected on the new subdomain.
Yesterday we install SSL on the subdomain, and nothing works.
[subdomain.mydomain.com...] works fine
[subdomain.mydomain.com...] throws the following error:
mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I know this kind of error occurs while you try to connect to a db in a diferent domain.
Is this correct? And if yes, what can i do?
we are running PHP 4.4.2, Apache 1.3.37 , Mysql 4.1.14
and we connect to our main db with :
$server_connect = mysql_connect("localhost", "user", "pass");
$db_connect = mysql_select_db("databasename", $server_connect) or die("Cannot Connect to Database");
When i connect through "localhost", i got the Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error.
When i connect with domain.com:port or ip:port methods I got Lost Connection error (although for the port part, i relly on phpinfo() - i am not sure if the port i use is the correct one)
Edit: Or maybe that's subdomain.localhost?
Or even subdomain.localhost.mydomain
or subdomain.localhost.mydomain.com
I'd try a few combinations to see if any help - sorry, I'm not that familiar with how PHP maps localhost when subdomains are involved.
[edited by: FalseDawn at 3:57 pm (utc) on Dec. 14, 2006]
Here are some examples, in both a procedural and object-oriented style. First procedurally:
$dbh = mysqli_init( );
// Set a new config file, disallow LOAD LOCAL INFILE and set the timeout to 600 seconds
mysqli_options($dbh, MYSQLI_READ_DEFAULT_FILE, '/home/phpb/mynew.cnf');
mysqli_options($dbh, MYSQLI_OPT_LOCAL_INFILE, false);
mysqli_options($dbh, MYSQLI_OPT_CONNECT_TIMEOUT, 600);
// Connect with the above options, as well as SSL
mysqli_real_connect($dbh,$host,$username,$password,$dbname,$port,$socket, MYSQLI_CLIENT_SSL);And then in an object-oriented style:
// Instantiate object
$mysqli = new mysqli( );
//Call the init method to allow setting of options
$mysqli->init( );
// Set a new config file, disallow LOAD LOCAL INFILE and set the timeout to 600 seconds
$mysqli->options(MYSQLI_READ_DEFAULT_FILE, '/home/phpb/mynew.cnf');
$mysqli->options(MYSQLI_OPT_LOCAL_INFILE, false);
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 600);
// Connect with the above options, as well as SSL
$mysqli->real_connect($host,$username,$password,$dbname,$port,$socket,MYSQLI_CLIENT_SSL);
I use https and have no problem using just localhost to connect, but then again I am not using a subdomain...
Meanwhile I thank you all for your efford and time..
I will post any usefull findings here, just in case someone else comes to the same problem with me.