Qt:Windows 10:QMYSQL驱动程序未加载 [英] Qt: Windows 10: QMYSQL driver not loaded
问题描述
简而言之:我正在尝试将Qt5.5链接到MySQL,但是它不起作用.
In Short: I am trying to link my Qt5.5 to MySQL but it is not working.
长话始于我尝试使用MySQL
的方式,
The long story begins when I tried to use MySQL
as in:
QSqlDatabase theDatabase = QSqlDatabase::addDatabase("QMYSQL");
但是当我运行我的应用程序时,我收到以下消息:
But when I run my application, I get the following messages:
QSqlDatabase:未加载QMYSQL驱动程序
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase:可用驱动程序:QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
这时,我在网上看了看如何解决这个问题.
At this point, I looked online to see how to fix this.
然后我在 Qt文档上找到了构建MySQL插件.因此,我遵循了指导:
Then I found on Qt Documentation that I need to build the MySQL plugin. So, I followed the guidance:
- 我下载了
mysql-installer-community-5.7.19.0
- 我试图安装MySQL.但是,在安装过程中,没有要安装的
Libs & Include Files
模块! - 但是我继续安装并成功在本地将MySQL57作为服务运行.
- 我当然不能构建插件,因为安装的文件中没有
sqldrivers
文件夹.
- I donwloaded
mysql-installer-community-5.7.19.0
- I tried to instal MySQL. However, during the installation, there was no
Libs & Include Files
Module to install !! - But I continued the installation and run MySQL57 succesfully as a service locally.
- I could not of course build the plugin because there is not
sqldrivers
folder in my installed files.
我开始在互联网上寻找解决方案.然后:
I started looking all over the internet for solution. Then:
- 根据此 youtube答案,我需要从
C:\Program Files\MySQL\MySQL Server 5.7\bin
至C:\Qt\Qt5.5.1\5.5\mingw492_32\bin
- According to this youtube answer, I needed to copy
libmysql.dll
fromC:\Program Files\MySQL\MySQL Server 5.7\bin
toC:\Qt\Qt5.5.1\5.5\mingw492_32\bin
我运行我的应用程序,但是我又遇到了同样的错误!所以:
I run my application, but again I have the same error !! So:
- 我将文件
libmysql.dll
从C:\Program Files\MySQL\MySQL Connector.C 6.1\lib
复制到了相同的位置C:\Qt\Qt5.5.1\5.5\mingw492_32\bin
,
- I copied the file
libmysql.dll
fromC:\Program Files\MySQL\MySQL Connector.C 6.1\lib
to the same locationC:\Qt\Qt5.5.1\5.5\mingw492_32\bin
,
但是,我再次遇到相同的错误.
However, again I have the same error.
我现在被困住了,不知道该怎么办.
I am now stuck, don't know what to do.
P.S .:我在Qt应用程序的.pro文件中有sql
P.S.: I have sql in my .pro file in Qt-application
推荐答案
下载32位版本的libmysql.dll;请在此处查看详细信息: qt 5.8 sql连接错误:Windows 10上未加载QMYSQL驱动程序
Download the 32-bit version of libmysql.dll; check here for details: qt 5.8 sql connection error:QMYSQL driver not loaded on windows 10
这篇关于Qt:Windows 10:QMYSQL驱动程序未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!