Can't connect to mysql server
#1

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
Reply
#2

Try use "127.0.0.1" in place of the "localhost" and see if it works
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)