View Full Version : mysql_connect(): Lost connection to MySQL server during query
latheesan 08-07-2006, 08:44 PM Hello,
i got this wierd error today when i accessed my website:
mysql_connect(): Lost connection to MySQL server during query
my website is on a linux server, but the mysql server is on a windows server.
Any idea on how i can fix this problem? Thanks in advance for any help :)
UK-Networks 08-08-2006, 07:17 AM Hi,
It is usually a server load problem, make sure your queries are as fast as possible and as few as possible.
Rgds,
Chris
latheesan 08-08-2006, 07:23 AM mm How do that? This is what i am trying to do:
/* Total Users Online */
mysql_connect("host.com", "root", "<snipped>") or die(mysql_error());
mysql_select_db("ragnarok");
$query = "SELECT count(*) as total FROM `char` WHERE (`online` = 1)";
$result = mysql_query($query) or die(mysql_error);
mysql_close();
$arr = mysql_fetch_array($result);
$users_online = $arr["total"];
zupanm 08-08-2006, 07:51 AM this has to be set on the mysql server side
[mysqld]
wait_timeout = 300
latheesan 08-08-2006, 12:39 PM Thanks for your reply. I am running a package called xampp (which has mysql v5 bundled) for windows.
Where or how can i edit that? my.ini file?
latheesan 08-08-2006, 12:54 PM oki, i found my.ini in C:\Windows\ folder and added the lines onto it and saved it and restarted the server.
Still no luck -> www.soulro.net/cp/
zupanm 08-08-2006, 01:36 PM try running that query from like the mysql client and see how long it takes.. you might have to extend it longer then 30 minutes or fine tune the query.. run this
explain SELECT count(*) as total FROM `char` WHERE (`online` = 1);
then paste the results... it could be easily fixed by tunning your query
latheesan 08-08-2006, 08:05 PM Thanks for your reply. I tried your suggestion. This is the result:
http://img83.imageshack.us/img83/1289/untitledkv6.png
I don't think the problem is the query it self, rather the connection from my website (hosted on a linux) to my mysql server (hosted on a windows xp)...
latheesan 08-09-2006, 07:03 PM OMG, what is wrong. I even reinstalled XAMPP and uploaded the databse, still there is no luck...
On my windows server, im running a game server, which uses my local host's mysql server.
On my website, which is on a linux server, it remotely connects to my mysql server hosted on my windows server to work out how many players are online.
Im guessing this, but, im i getting this error because, my game server is continoisuly using the mysql server, not allowing my website to query the mysql server??? If so, how can i fix this sorta problem??? Please advice -_-
AlReece45 08-09-2006, 08:01 PM This might help:
dev.mysql.com/doc/refman/5.0/en/gone-away.html
latheesan 08-09-2006, 08:20 PM Thanks allot for your reply, i been to that site first thing and tried everything become posting my problem here.
i set wait_timeout = 3000000000000000 (as suggested on the website) and also did mysqladmin --user=root ping and got the result "mysql is alive"
iuno what else i have to do to get this working...
I have a suggestion. By switching to older mysql server version, i.e. 4.x, will this problem go away??? atm, xampp uses mysql 5.x
AlReece45 08-10-2006, 01:32 PM Right now it looks like its working. Are you running mysqladmin from the server MySQL is on or the server that was/is having trouble connecting?
latheesan 08-10-2006, 01:36 PM Sorry, but it still not working. I having trouble with my website, that just won't connect to my mysql server at home.
http://www.soulro.net/cp/index2.php (see, its not working)
AlReece45 08-10-2006, 02:43 PM Well, how do you have the permissions set up on the MySQL Server? Like what hosts do you have it accepting from?
|