I want to connect to a MySQL database from a Qt C++ application. Database is located on a host and is available on internet. I have the MySQL username, password and IP of host and a port number (that I don't know what is)
Application::getInstance()->db = QSqlDatabase::addDatabase("QMYSQL");
QSqlDatabase *db = &Application::getInstance()->db;
db->setHostName("64.34.119.12"); // The string is IP address of my host (not real)
db->setDatabaseName("foo");
db->setUserName("root");
db->setPassword("password");
db->open(); // returns false
I tried to pass IP address to db->setHostName()
but not worked: Connection fails.