Mysql connection failed
#1

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

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

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

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

Can you show your logs?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)