How can QMYSQL driver be loaded?

115 views Asked by At

In How to solve "QSqlDatabase: QMYSQL driver not loaded", this answer says that libqsqlmysql.a and libqsqlmysqld.a files should exist in <QtDir>\mingw73_xx\lib folder.

But I cannot get libqsqlmysql.a and libqsqlmysqld.a of any place such as GitHub. I only found libqsqlmysql.dll and libqsqlmysqld.dll files.

Code:

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

db.setDatabaseName("C:/ProgramData/MySQL/MySQL Server 8.0/Data/world/city.idb");

db.setHostName("localhost");

db.setUserName("root");

db.setPassword("1234567890");

The output:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
1

There are 1 answers

0
mori On BEST ANSWER

Problem was solved ! download from https://github.com/thecodemonkey86/qt_mysql_driver/releases copy

libcrypto-3-x64.dll , libmysql.dll ,libssl-3-x64.dll

to <Qt Dir>\mingw_64\bin and

qsqlmysqld.dll , qsqlmysql.dll

to <Qt Dir>\mingw_64\plugins\sqldrivers . The important point is that I was only able to create the program with msvc and could not create my program with mingw.