Hi,

I have QT mysql connectivity issue.

I have created one docker instance where I have installed mysql. This mysql instance is running
on port 6603 and not a regular port of 3306.
This port is open and is accessible from outside as well. Now I am connecting to this mysql instance
from all other applications which is not built using QT, like I am able to connect using node js or
any other 3rd party mysql editor. This means there is no connectivity issue.
But when I try to connect to this server using QSqlDatabase, it is either not connecting or says access denied.
However, if I change the above server port from 6603 to default 3306, QT application is able to connect.
Not getting where the things are going wrong. I have used below code of QT.

Qt Code:
  1. QJsonObject jo = getConnectionDetails(); // getConnectionDetails has all values of actual connections.
  2. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL",jo.value("conn_name").toString());
  3. db.setHostName(jo.value("hostname").toString());
  4. db.setDatabaseName(jo.value("dbname").toString());
  5. db.setUserName(jo.value("username").toString());
  6. db.setPassword(jo.value("password").toString());
  7. db.setPort(jo.value("port").toInt());
  8. if (!db.open()){
  9. error = db.lastError().databaseText();
  10. qDebug() << "Connection error: " + error;
  11. return false;
  12. }
  13. return true;
To copy to clipboard, switch view to plain text mode 

Above code is part of connector function.
Please suggest why this happening?

Cheers

Manish