BlueG's MySQL - Too Many Connections
#1

Hi all,

Using BlueG's MySQL plugin, latest version. Trying to connect to MySQL databae, code below.

Код:
public OnGameModeInit(){
	SetGameModeText("BCL-RP 0.1");

	//Connect to MySQL Database
  	if(mysql_connect(DB_HOST, DB_USER, DB_NAME, DB_PASS)){
	    print("Successfully connected to MySQL Database!");
	}else{
	    print("Failed connection to MySQL Database!");
	    GameModeExit();
	}

	return 1;
}
The successful connection message is printed fine to the console. However, when I check the MySQL log, I have this error over and over again:

[18:55:14] [ERROR] CMySQLConnection::Connect - (error #1040) Too many connections

If anyone has any ideas on whats causing this, or how to fix, then please advise. I've already checked the MySQL max connections variable, and that is set to 151.

Thanks
Reply
#2

You need to use mysql_errno to check if the connection was successful.

As for the error #1040, I'm not sure if the connection is still active if you don't close the connection with mysql_close when shutting down the server.

Another interesting thing is this: http://stackoverflow.com/a/34176072
Reply
#3

Hi,

Thanks for the advice.

I've added the connection close to the onGameModeExit...made no difference unfortunately.

Had a look at the link you posted to with no success unfortunately.
Reply
#4

Have you tried stopping and starting the MySQL service?
Reply
#5

Im now getting the following errors in the mysql log:

Код:
[20:44:41] [ERROR] mysql_errno - invalid connection handle (id: 0)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
[20:44:42] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on '127.0.0.1' (10061)
This is now my code:

Код:
public OnGameModeInit(){
	SetGameModeText("BCL-RP 0.1");

	//Connect to MySQL Database
	mysql_connect(DB_HOST, DB_USER, DB_NAME, DB_PASS);
  	if(mysql_errno() == 0){
	    print("Successfully connected to MySQL Database!");
	}else{
	    print("Failed connection to MySQL Database!");
	    GameModeExit();
	}

	return 1;
}
Any suggestions? Restarting mysql has done nothing, but thanks
Reply
#6

The service has probably not started. Is it on Windows or Linux?
Reply
#7

It has started, I'm using phpmyadmin and can access the database and data within inside it, including full CRUD functionality. On windows.
Reply
#8

Service hasn't started as Konstantinos already said, or the server is not localhost, but it is a normal IP address. Can you login to your phpMyAdmin? If so, check the middle-up-side where it's a grey template and it's written Server: xxx - usually the xxx should be localhost but sometimes it isn't. You should check that and adjust your DB_HOST define to the xxx.
Reply
#9

I've tried connecting both via localhost and via the specific localhost IP..no difference. Is my pawno code correct in the above post? Wondered if it was something with that
Reply
#10

what is your DB_HOST at?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)