When using a database connection in QT 5, the following error pops up:
Qsqldatabase:qmysql Driver not loaded
Qsqldatabase:available drivers:qsqlite qmysql QMYSQL3 qodbc QODBC3 qpsql QPSQL7
As can be seen from the above error, the error occurs when the MySQL database driver is not loaded.
There are two general cases of this error:
The first type: no MySQL driver, then check the Qt\5.3\msvc2013_64_opengl\plugins directory for Qsqlmysql.dll, if not, it means that Qt does not have the corresponding MySQL driver. At this time, in qsqldatabase:available drivers:qsqlite qmysql QMYSQL3 qodbc QODBC3 qpsql QPSQL7 Error, there is no qmysql item.
The workaround is to copy the Qmysql.dll to the plugins directory. How do I get it? http://blog.163.com/e_rommel/blog/static/187383045201292422139149/or Http://dev.wo.com.cn/bbs/viewthread.jsp?tid =140945&extra=page%3d1.
The second type: library support is not perfect.
The workaround is to copy the Libmysql.dll under Mysql\mysql Server 5.7\lib to Qt\5.3\msvc2013_64_opengl\bin.
Qsqldatabase:qmysql Driver not loaded solution