QT installed in the D:\Qt directory, the QT 5.4.1 connection MySQL database, found the following error
Qsqldatabase:qmysql driver not loadedqsqldatabase:available drivers:qsqlite qmysql qmysql QMYSQL3 qodbc
Go to the D:\Qt\Qt5.4.1\5.4\mingw491_32\plugins\sqldrivers directory and find out that there is a MySQL driver
Google a bit, it is said that the driver is satisfied with the dependency, not satisfied, need to recompile, then recompile it.
Download the 5.6 version of the 32-bit zip file to MySQL website and unzip it to D:\MYSQL-WIN32 (it must be 32-bit MySQL, otherwise the compilation will not pass).
Unzip the Qt5.4.1 zip source to G:\Qt\qt-everywhere-opensource-src-5.4.1.
Open MinGW command-line tool
Switch to QT source directory
CD G:\Qt\qt-everywhere-opensource-src-5.4.1\qtbase\src\plugins\sqldrivers\mysql\
Generate makefile
Qmake "Includepath+=d:\mysql-win32\include" "Libs+=d:\mysql-win32\lib\libmysql.lib"-O Makefile Mysql.pro
Compile
Mingw32-make
After a successful compilation, the MySQL driver file will be generated in G:\Qt\qt-everywhere-opensource-src-5.4.1\qtbase\plugins\sqldrivers.
Copy Qsqlmysql.dll and Qsqlmysqld.dll to D:\Qt\Qt5.4.1\5.4\mingw491_32\plugins\sqldrivers to replace the original file.
Then copy the D:\MySQL-Win32\lib\libmysql.dll to the C:\Windows directory.
This allows QT to connect to the MySQL database.
Qt 5.4.1 compiled MySQL driver, connect MySQL database