Can't connect to mysql server - 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: Can't connect to mysql server (
/showthread.php?tid=511758)
Can't connect to mysql server -
jcvag44800 - 07.05.2014
Hello,
There is my code:
Код:
#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_PASS ""
#define MYSQL_DB "larp2"
forward MySQLConnect(sqlhost[], sqluser[], sqldb[], sqlpass[]);
MySQLConnect(MYSQL_HOST,MYSQL_USER,MYSQL_DB,MYSQL_PASS);
public MySQLConnect(sqlhost[], sqluser[], sqldb[], sqlpass[])
{
print("Connexion а la base de donnйes..."); // Connecting to the database
if(mysql_connect(sqlhost,sqluser,sqldb,sqlpass))
{
print("Connexion а la base de donnйes rйussie."); // success
return 1;
}
else
{
print("Connexion а la base de donnйes йchouйe."); // !success
if(mysql_connect(sqlhost,sqluser,sqldb,sqlpass))
{
print("Connexion а la base de donnйes rйtablie."); // success
return 1;
}
else
{
print("Connexion а la base de donnйes perdue. Le serveur est eteint."); // close server
SendRconCommand("exit");
return 0;
}
}
}
So, I try to connect my server to my database on my computer (using wamp).
But, my server say all time that the connection has been established while my database server is off...
There is the mysql debug log:
SQL SERVER OFF:
Код:
[13:44:51] CMySQLHandler::CMySQLHandler() - constructor called.
[13:44:51] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "larp2" | Username: "root" ...
[13:44:52] CMySQLHandler::Connect() - Can't connect to MySQL server on 'localhost' (10061) (Error ID: 2003)
SQL SERVER ON:
Код:
[13:42:29] CMySQLHandler::CMySQLHandler() - constructor called.
[13:42:29] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "larp2" | Username: "root" ...
[13:42:29] CMySQLHandler::Connect() - Connection was successful.
[13:42:29] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
Logs are good...
Regards
Re: Can't connect to mysql server -
Blademaster680 - 07.05.2014
Try use "127.0.0.1" in place of the "localhost" and see if it works
Re: Can't connect to mysql server -
Calgon - 08.05.2014
I had this problem, I had two copies of MySQL server running at the same time. Check for any conflicts that could be causing a problem.