PDA

View Full Version : [SOLVED] can't connect to remote mysql server



Pluvius
16th April 2012, 11:26
Hello! I've built the Qt Driver for Mysql and it works fine, when I log into localhost mysql is working and ready but whenever I try to access a remote mysql over the network (not local) it gives me an error, even though I have the credentials to connect (I can test it via mysql console) here's a code snippet about my connection information, if you have some time plz look it up




Database::Database()
{
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("66.23.54.32"); // fake ip ;)
db.setPort(3306);
db.setDatabaseName("stephan");
db.setUserName("root");
db.setPassword("root");
db.open();


}

void Database::openConnection(){

if (!db.open())
{ QMessageBox::critical(0,QObject::tr("Database Error"),
db.lastError().text());
}

else qDebug()<<"SUCCESS";

}

QSqlDatabase Database::getDb(){

return db;
}




much appreciated

ChrisW67
16th April 2012, 12:57
So what does QSqlDatabase::lastError() tell you?

Pluvius
16th April 2012, 14:42
Hello again!
turns out it had something to do with NAT settings + the server was down when I tried to access it through Qt

Thank you for replying :)