Qt: Windows 10: QMYSQL driver not loaded
Solution 1
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
Solution 2
My version is QT 5.11.1. I met same problem.
I copied libmysql.dll
from
C:\Program Files\MySQL\MySQL Server 5.7\lib
to
C:\Qt\Qt5.11.1\5.11.1\mingw53_32\bin.
Finally,I succeeded.
McLan
Updated on June 14, 2022Comments
-
McLan almost 2 years
In Short: I am trying to link my Qt5.5 to MySQL but it is not working.
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 driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
At this point, I looked online to see how to fix this.
Then I found on Qt Documentation that I need to build the MySQL plugin. So, I followed the guidance:
- 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:
- 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:
- 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.: I have sql in my .pro file in Qt-application
-
rakib_ over 6 yearsMaybe the most likely solution if all the scenario you have mentioned is to build Qt with you toolchain and produce
libmysql.dll
and trying using that one. Actually I faced this problem on GNU/Linux and rebuilding Qt solved my case.
- I donwloaded
-
McLan over 6 yearsThanks, it works now. it doesn't work though with 64-bit. Many thanks again
-
Don Joe over 4 yearsThank you so much! I've been looking for a solution for two days, and now it finally works.
-
Jeruntu over 3 yearsThis also worked for me! libmysql.dll has to go to the bin folder of qt installation.