安装QMYSQL驱动程序 [英] Installing QMYSQL driver
问题描述
基本上,当我尝试连接到mysql数据库时,出现此错误:
Basically when I try to connect to the mysql database i get this error:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3
我尝试安装驱动程序,仅从 http://www.qtcentre.org/threads/45295-using-mysql-plugin 这样做: http://puu.sh/3nyG9.png
I tried to install the drivers, extracting just qtbase from http://download.qt-project.org/official_releases/qt/5.0/5.0.2/single/qt-everywhere-opensource-src-5.0.2.zip and placing it in my Qt directory. I have also followed this guide by inbush: http://www.qtcentre.org/threads/45295-using-mysql-plugin doing this: http://puu.sh/3nyG9.png
inbush说将libmysql.dll从C:\ mysql \ bin复制到C:\ Qt \ bin,但是我没有在bin中找到libmysql.dll,但是我确实在lib中找到了它.因此,我把它带到了我的Qt \ bin,并注意到只是这些文件 http://puu.sh /3nB5m.png ,所以我想将其放在Qt \ lib中.我尝试重新运行我的项目,但它仍然给我同样的错误.我的.pro文件确实具有Qt + = sql,之后我确实运行了qmake.我在做什么错了?
inbush says to copy libmysql.dll from C:\mysql\bin to C:\Qt\bin but I didn't find libmysql.dll in bin, but I did find it in lib. So I took that and went to my Qt\bin, and noticed that it was just these files http://puu.sh/3nB5m.png so I thought to place it in Qt\lib instead. I tried re-running my project but it still gave me the same error. My .pro file does indeed have Qt += sql, and I did run qmake afterwards. What am I doing wrong?
推荐答案
Take a look at this post for Qt5, there's also a seperate set of instructions for Qt4 (although somewhat similar).
- 下载MySQL版本
- 下载Qt源
- 为Qt构建MySQL插件
- 将DLL从MySQL安装文件夹复制到Qt文件夹(请参见上面的链接)
- 将为Qt MySQL插件构建的DLL复制到Qt文件夹
显然,在分发时,您需要记住将这些DLL打包在一起(始终检查依赖关系行程序)
And obviously, when you distribute you'll need to remember to package those DLLs together (always check dependency walker)
这篇关于安装QMYSQL驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!