Mysql connection failed - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Mysql connection failed (
/showthread.php?tid=528932)
Mysql connection failed -
devil shill - 30.07.2014
Hey guys, Im wondering a long time why my connection keeps failing as i have the correct information and i can connect to other mysql servers.
(Yep mine is Ubuntu VPS)
Код:
/****** MYSQL DATABASE DEFINES *****/
#define DB_HOST "localhost"
#define DB_USER "root"
#define DB_PASS "password" //Private Ofc
#define DB_ "test"
Код:
public ConnectMySQL() {
LogCallback("ConnectMySQL");
mysql_connect(DB_HOST, DB_USER, DB_, DB_PASS);
if(mysql_ping()==1) {
printf("[MySQL]: Connected successfully to database '%s'", DB_);
} else {
printf("[MySQL]: Connection failed to database '%s'", DB_);
}
LogCallback("ConnectMySQL");
return 1;
}
Logs doesn't show anything useful that has something to do with the connection problem, Hope some of you might know why this is occurring
Re : Mysql connection failed -
SlimDkhili - 30.07.2014
If you don't have SQL database in your server , try install it
Check if you have the database User is root , and the password of root user is "password" , usually and randomly your sql server passis nothing, change "password" to ""
Re: Mysql connection failed -
d3ll - 30.07.2014
pawn Код:
static connection_handle;
public ConnectMySQL() {
LogCallback("ConnectMySQL");
connection_handle = mysql_connect(DB_HOST, DB_USER, DB_, DB_PASS);
if(mysql_errno(connection_handle) != 0){
printf("[MySQL]: Connection failed to database '%s'", DB_);
} else {
printf("[MySQL]: Connected successfully to database '%s'", DB_);
}
}
Try this, not much changed.
Also, make sure that your SQL server is running and optamized to your credentials.
Re: Mysql connection failed -
devil shill - 30.07.2014
Quote:
Originally Posted by d3ll
pawn Код:
static connection_handle;
public ConnectMySQL() { LogCallback("ConnectMySQL"); connection_handle = mysql_connect(DB_HOST, DB_USER, DB_, DB_PASS);
if(mysql_errno(connection_handle) != 0){ printf("[MySQL]: Connection failed to database '%s'", DB_); } else { printf("[MySQL]: Connected successfully to database '%s'", DB_); } }
.
|
Did not work and ofcours all the credentials are correct had this problem for some time so i checked it 3 times everytime i uploaded it to the vps, Any other ideas ?
Re: Mysql connection failed -
coole210 - 30.07.2014
Can you show your logs?