为什么QT5.2中未加载QMYSQL驱动程序? [英] Why QMYSQL driver not loaded in QT5.2?

查看:369
本文介绍了为什么QT5.2中未加载QMYSQL驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序是使用QT5.2编写的,并且使用mysql.我听说QT5.2已经包含MYSQL驱动程序.但是,当我编译并运行程序时,它已成功编译,但运行失败并出现错误:

My program is write with QT5.2 and use mysql. I heared that QT5.2 contains MYSQL driver already. However, when I compile and run my program, it is compiled successfully but runned failed with error:

   QSqlDatabase: QMYSQL driver not loaded
   QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

我的程序是这样的:

     QSqlDatabase db=QSqlDatabase::addDatabase("QMYSQL");
     db.setHostName("localhost");
     db.setDatabaseName("tradingsystem");
     db.setUserName("root");
     db.setPassword("");
     if(!db.open())
     {
          //.....;
     }

然后在.pro中添加以下内容:

And in .pro I add this:

    QT += sql

XAMPP提供了Mysql,我的操作系统是win7-x64-sp1-ultimate,XAMPP版本1.8.2是,系统路径如下:

Mysql is provided by XAMPP.My OS is win7-x64-sp1-ultimate, and XAMPP Version 1.8.2.System Path is as follow:

    C:\Program Files (x86)\SepanderSoft;
    C:\Program Files (x86)\Intel\iCLS Client\;
    C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
    C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
    C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;
    C:\Program Files\Intel\WiFi\bin\;
    C:\Program Files\Common Files\Intel\WirelessCommon\;
    C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;
    C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;
    C:\Program Files\Microsoft\Web Platform Installer\;
    C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;
    C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;
    C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
    D:\Software\MySQL\MySQL Enterprise Backup 3.8.2\

XAMPP的位置是:

XAMPP location is :

    D:\XAMPP

QT位置是:

    D:\Software\Qt

我已经在D:\ Software \ MySQL中安装了mysql server-5.6-64bit,当它与XAMPP中的mysql冲突时,我卸载了mysql server-5.6-64bit.

I have installed mysql server-5.6-64bit in D:\Software\MySQL, and when it conflicted with mysql in XAMPP, I uninstalled mysql server-5.6-64bit.

推荐答案

我遇到相同的错误,并通过复制文件

I met with the same error and fixed it successfully by copying file

C:\Program Files (x86)\MySQL\MySQL Connector.C 6.1\lib\libmysql.dll

进入

C:\Qt\Qt5.3.1\5.3\mingw482_32\bin

Youtube链接

这篇关于为什么QT5.2中未加载QMYSQL驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆