How to connect to a MySQL database through ODBC from Qt application?
I have a freshly-installed MySQL server, which listens on localhost:3306. What is the correct way to connect to it from my Qt application? It turned out that I need to add MySQL to the ODBC data sources. I did that after following this video tutorial - https://youtu.be/K3GZidOwGmM . After I had added the DSN, I successfully connected to the MySQL server using this code: QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); db.setDatabaseName("Driver={MySQL ODBC 5.3 Unicode Driver};DATABASE=test;"); db.setUserName("root"); db.setPassword("password"); if (!db.open()) { qDebug() << db.lastError()