提示Driver not loaded那是qt的mysql驱动不在, 需要自己编译.?
(1)下载c版本的32位mysql驱动lib
下载地址:?MySQL :: Download MySQL Connector/C (Archived Versions)
下载的libmysql.dll 放到? D:\install\qt5_12_11\5.12.11\msvc2017\bin\
(2) 编译32位的qt mysql驱动
qt编译器记得设置为32位, 要不然与下载的32位的libmysql.lib对应不上, 就编译失败了.
?
D:\install\qt5_12_11\5.12.11\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro
如何编译参照:?
QT 5.12.11 mysql8 提示Driver not loaded Driver not loaded_liyang_nash的专栏-CSDN博客
#这是mysql.pro
TARGET = qsqlmysql
HEADERS += $$PWD/qsql_mysql_p.h
SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
#QMAKE_USE += mysql
OTHER_FILES += mysql.json
PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
include(../qsqldriverbase.pri)
#INCLUDEPATH +=E:/install/mysql-8.0.16-winx64/include/
#LIBS += E:/install/mysql-8.0.16-winx64/lib/libmysql.lib
INCLUDEPATH +=D:/workspace/libs/mysql-connector-c-6.1.11-win32/include/
LIBS += D:/workspace/libs/mysql-connector-c-6.1.11-win32/lib/libmysql.lib
DESTDIR = ../mysql/mysqlDll32
之后就生成qsqlmysql.dll??qsqlmysql.lib??qsqlmysqld.dll?qsqlmysqld.lib了. 在mysqlDll32目录下.
拷贝: ?D:\install\qt5_12_11\5.12.11\Src\qtbase\src\plugins\sqldrivers\mysql\mysqlDll32生成的 到 ? : ?D:\install\qt5_12_11\5.12.11\msvc2017\plugins\sqldrivers\
然后32位的qt就可以利用32位的qt驱动来连接64位的mysql啦.?
|