MySQL wont connect.
#1

A few days ago I setup a SA-MP Server with a MySQL database. I have setup the password and everything right but everytime I start my server I still get "[MYSQL]: [ERROR]: Connection to `samp` failed!"

Also I changed my password in the MySQL tab to "password" for now, with this.

Код:
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
And then in "confic.inc.php" aswell. XAMPP still connects to phpmyadmin so I dont get why SAMP wont. Here's my code.

Код:
#define MySQL_HOST "localhost"
#define MySQL_USER "root"
#define MySQL_PASS "password"
#define MySQL_DB "samp"

public OnGameModeInit()
{
    mysql_debug(1);
    mysql_connect(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB);
    if(mysql_ping() == 1)
    {
       mysql_debug(1);
       printf("[MYSQL]: Connection to `%s` succesful!", MySQL_DB);
    }
    else
    {
        printf("[MYSQL]: [ERROR]: Connection to `%s` failed!", MySQL_DB);
    }
    mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(41), score INT(20), money INT(20), IP VARCHAR(16) )");
    return 1;
}

public OnGameModeExit()
{
    mysql_close();
    return 1;
}
Reply
#2

lol fixed it. MySQL_DB and MySQL_PASS were just in the wrong spot. Switched them and it works now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)