Environment:
QT 5.11
Mysql 5.5
MSVC 2015 compiler
All of the above are 64-bit
Symptoms are:
Connection database is normal under Debug, the database failed to connect under release
Tips are as follows:
Qsqldatabase:qmysql driver not loadedqsqldatabase:available drivers:qsqlite qmysql QMYSQL3 qodbc QODBC3 qpsql QPSQL7
Note that there is no need to manually compile MySQL driverin this case, because QT has its own
According to the various methods on the Web, paste the DLL everywhere, including the EXE sibling directory, and the main under add
Qapplication::addlibrarypath ("./plugins");
etc... And Fq looked at a variety of methods, tossing all morning useless.
Final Solution:
Download mysql-connector-c on the MySQL website https://dev.mysql.com/downloads/connector/c/
(Mysql-connector-c-6.1.11-winx64.msi)
Install and then add the. qrc file in the QT project
6.1+ =-l$$"C:\Program files\mysql\mysql Connector C 6.1\lib"
Purge, re-qmake, build, open discovery still fails, and debug succeeds.
No fruit, finally delete the project's release folder, re-release under Build, run, success.
Then pack and publish, everything works.
..
Qsqldatabase:qmysql Driver not loaded solution (normal under Debug, release error)