MySQL wont connect. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL wont connect. (
/showthread.php?tid=577766)
MySQL wont connect. -
WilliamOordt - 13.06.2015
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;
}
Re: MySQL wont connect. -
WilliamOordt - 14.06.2015
lol fixed it. MySQL_DB and MySQL_PASS were just in the wrong spot. Switched them and it works now.