SA-MP Forums Archive
MySQL reconnect? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL reconnect? (/showthread.php?tid=493634)



MySQL reconnect? - Riwerry - 09.02.2014

Hello guys, is possible to make automatic reconnect to MySQL database if it lose connection for some reason? Or what will happen if server lost connection to MySQL for example when player is registering?


Re: MySQL reconnect? - Konstantinos - 09.02.2014

In the latest versions of MySQL, there is a parameter (autoreconnect) that is set to true by default so it will reconnect.


Re: MySQL reconnect? - Riwerry - 09.02.2014

I am using R36-2 latest Blue G plugin, hope it have autoreconnect


Re: MySQL reconnect? - Konstantinos - 09.02.2014

It does. You can always open a_mysql.inc and search for mysql_connect function so you can see the parameters:
pawn Код:
native mysql_connect(const host[], const user[], const database[], const password[], port = 3306, bool:autoreconnect = true, pool_size = 2);



Re: MySQL reconnect? - Riwerry - 09.02.2014

And how it knows / when it check if it lost connection to mysql?


Re: MySQL reconnect? - RajatPawar - 09.02.2014

That is internal, the scripter need not worry about it. You can always use
pawn Код:
mysql_debug( true )
and it will put all this into a mysql_log.txt file. (empty connection - reconnecting, and stuff)


Re: MySQL reconnect? - Jimmy0wns - 09.02.2014

Or just make a timer that reloads/refreshes the connection every 5/10 minutes, depending on your plugin.