PDA

View Full Version : Problems with mysql connection.


D1am0nd
03/05/2016, 04:30 AM
Hi all. I am very new at this and I don't know how to fix the following problem. Each time when I start up the server and check mysql_log.txt, there appears this:

[05:28:42] [ERROR] CMySQLConnection::Connect - (error #1045) Access denied for user 'zsampstar1'@'localhost' (using password: NO)
[05:28:42] [ERROR] CMySQLConnection::Connect - (error #1045) Access denied for user 'zsampstar1'@'localhost' (using password: NO)
[05:28:42] [ERROR] "mysql_errno" - invalid connection handle (ID = 0)
[05:28:42] [ERROR] "mysql_tquery" - invalid connection handle (ID = 0)
[05:28:42] [ERROR] "mysql_tquery" - invalid connection handle (ID = 0)


Maybe that's because of some mistake at GameModeInIt? Well, this is how it looks like,

public OnGameModeInit()
{
print("====================="R_COD_NAME" "VERSION"=====================");

mysql_log(LOG_ERROR | LOG_WARNING);

mysql_connect("127.0.0.1", "zsampstar1", "codsamp", "", 3306, true);

if(mysql_errno(g_pSQL) != 0)
{
print("#Failed to connect to MySQL db");
print("====================="R_COD_NAME" "VERSION"=====================");
SendRconCommand("exit");
return 1;
}

print("#Connected to MySQL db");

Also I use MySQL plugin R34.

Please help me to solve this problem! Thank you in advance.

Vince
03/05/2016, 05:16 AM
I think the error message could hardly be any more clear. The user you're trying to connect with doesn't have permission to do so. This has nothing to do with the script but with permissions in the MySQL server.

D1am0nd
03/05/2016, 11:13 AM
Oh.. well, then I will try to contact my host regarding to this issue.

P.S. Do you know where to download mysql R31?

kaisersouse
03/05/2016, 11:24 AM
You left the password parameter blank:


mysql_connect("127.0.0.1", "zsampstar1", "codsamp", "", 3306, true);


should be

mysql_connect("127.0.0.1", "zsampstar1", "codsamp", "yourpasswordgoeshere", 3306, true);

You need to set up a new MySQL user named 'zsampstar1', give it a password, and give it rights to the DB/schema named "codsamp".

You then need to enter that password (for zsampstar1) in your mysql_connect query, in the spot where I put yourpasswordgoeshere

Erwin.
03/05/2016, 11:35 AM
DELETE