Problems with mysql connection.
#1

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,
PHP код:
public OnGameModeInit()
{
    print(
"====================="R_COD_NAME" "VERSION"=====================");
    
    
mysql_log(LOG_ERROR LOG_WARNING);
    
    
mysql_connect("127.0.0.1""zsampstar1""codsamp"""3306true);
    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.
Reply
#2

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

Oh.. well, then I will try to contact my host regarding to this issue.

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

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

DELETE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)