This worked for me and I used:
OS: Windows
Qt version: 5.13.1 and 5.13.2
Qt creator: 4.10.1
compiler: mingw73_32
Step by step:
Download msys & msysgit
Open the cmd of msys and type these commands (keep in mind that the second and third command do not contain cd. You need to call the .exe files from the mysql path):
cd <path to libmysql.lib>
C:/msysgit/mingw/bin/reimp.exe libmysql.lib
C:/msysgit/mingw/bin/dlltool.exe -k -d libmysql.def -l libmysql.a
go to the qt cmd called: Qt <version> (<compiler>). Use the one with the mingw32 compiler.
execute the following commands:
cd C:/Qt/Qt<version>/<version>/Src/qtbase/src/plugins/sqldrivers
qmake
sqldrivers.pro
open
mysql.pro and make sure that it looks like this (change the include path and the lib path, but make sure that the include path and the depend path are the same!) and save after you finished editing it:
TARGET = qsqlmysql
HEADERS += $$PWD/qsql_mysql_p.h
SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
#QMAKE_USE += mysql
LIBS += -L'C:/MySQL/lib/'
-llibmysql
INCLUDEPATH += 'C:/MySQL/include'
DEPENDPATH += 'C:/MySQL/include'
OTHER_FILES += mysql.json
PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
include(../qsqldriverbase.pri)
execute the following commands:
qmake
mysql.pro
qmake "INCLUDEPATH+=<includepath>" "LIBS+=<libpath>/libmysql.lib"
mysql.pro
mingw32-make
go to C:/Qt/Qt<version>/<version>/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers in the file explorer. You should see these four files now:
qsqlmysql.dll
qsqlmysqld.dll
qsqlmysql.a
qsqlmysqld.a
copy them and place them into: C:/Qt/Qt<version>/<version>/mingw73_32/plugins/sqldrivers