FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Error connecting to mysql ; please help





ammonkc
I have an apache server on one machine and a mysql on another server. the web server cannot connect to the mysql db.
this is the error:
Quote:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in /usr/local/apache/htdocs/config.php on line 6
error connecting to mysql:Lost connection to MySQL server during query


I have set up the grant tables the exact same way I have always done it in the past.
Code:
GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO user@"%"
-> IDENTIFIED BY 'password';


Both servers are on the same internal network. It seems like the web server can see the mysql server because it returns a mysql error. so I'm assuming that its not a network or firewall issue. I don't think its my connection script, because I can connect to a database on a testing (dev) server.
this is my php connection script:
webserver: 10.4.87.240
mysql: 10.4.87.241
Code:
<?php
$host="10.4.87.241";
$user="user";
$password="password";
$db="database";
$conn=mysql_connect($host,$user,$password) or die ("error connecting to mysql:".mysql_error());
$select_db = mysql_select_db($db,$conn) or die (mysql_error());
?>

Is this a problem with my network (ie firewall configuration), or a problem with my mysql grant tables, or a problem with my php connection script? I've never gotten this error before. I'm kinda stuck right now. Any help would be greatly appreciated.
Thanks
hexkid
I cannot solve your problem, but read these pages ... maybe you can solve it for yourself

http://dev.mysql.com/doc/refman/5.0/en/communication-errors.html
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html
steveadams617
Have you tried running the MySQL and webserver on the same machine and testing the code? That would rule out basic problems with the code or versions of MySQL clashing with versions of PHP or something. Be sure to install exactly the same version of MySQL on the webserver that is on your remote machine.

Have you tried running different queries to make sure that you aren't having SQL problems? Maybe write some sample code and just try opening "select * from MyTable;"
steveadams617
Maybe you want to post the SQL statement for people to review?
ammonkc
its having problems with just establishing a connection to mysql. the connecion script is where it craps out so I can't even run queries. I'm pretty sure its not version clashing, because they are both the most recent releases.

I've been poking around in the my.cnf file and I'm starting to think that its because the "skip-network" option is enabled. From what I understand this is more secure if all apps are on the same host. I'm not sure how to do it yet, but I think I need to bind a tcp/ip connection to an address with a "bind-address" option in the my.cnf file.
ammonkc
Oh, yeah, I don't know how I forgot to mention this in the first post. This is a site that has been up and running in production for a couple of months now. I'm just preping a new server with upgraded hardware to migrate the site to. So I'm pretty sure that all my queries and the php code is working fine. I will be moving the site onto a new server so that I can migrate the whole thing to a colocation soon.
ammonkc
I figured it out. it was two things, it was a firewall configuration issue and the my.cnf "skip-networking" thing. thanks for the posts.

I have a new problem that is unrelated now. I'll post it in a new thread.
Related topics
simple php problem, please help...
phpBB2 ERROR PLEASE HELP
Shout Boxes, NO MySQL PLEASE
Problem with MySQL Server Please Help!!
mysql base error please help
Frontpage error please help
THIS IS DRIVING ME INSANE!! PLEASE HELP!
Internal Server Error in Joomla, Please help!
please help im trying to install a wiki but it returns 500
what is wrong with this query? Please please help!
How can I log in to MySQL? Please help!
URGENT: Please help - site down due to database error
Fatal Error in frihost please help me
404 Not Found error was encountered (PLEASE HELP!!!)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.