Brandon Clark
Brandon Clark

Reputation: 796

Qt remote database with MySql?

What is the best way to add remote MySql database connectivity.

I have attempted using the QODBC driver with no luck, I believe another issue may be that this is a shared server but believe I have the right settings according to my host.

Here is my current attempt:

bool CardSQL::connectSQL(void){
     db = QSqlDatabase::addDatabase("QODBC"); 
     db.setHostName("173.254.28.127");// Tried www.themindspot.com & ip with http:// and https:// 
     db.setPort(3306);
     db.setDatabaseName("dbName");
     db.setUserName("dbUser");
     db.setPassword("dbPass");
     bool ok = db.open();
     return ok;
}

I check 'ok' in a if statement and it keeps coming back failed.

Upvotes: 0

Views: 2798

Answers (1)

jdi
jdi

Reputation: 92569

My guess is that your MySQL server on your justhost.com shared host is not running on a public network interface, and is only accessible via localhost (meaning you have to be running your apps locally on the server to connect). If there is an option to do it, its probably not currently doing it.

Some cpanel configurations have a "Remote Database Access Hosts" option which lets you specify specific external domains that are allowed to connect to your MySQL database.

Also, for mysql you would probably be using the QMYSQL database driver.

Upvotes: 3

Related Questions