QMYSQL driver not loaded
-
wrote on 6 May 2020, 21:40 last edited by
Hello everyone!
I am trying to connect my application to a local database, through the MYSQL connector, but the connection not work. I searched the forum and saw that it is a common problem, but I haven't found the solution.This is my code:
Initially the error was:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7Next, I put qsqlmysql.dll into :\Qt\5.14.2\mingw73_32\plugins\sqldrivers, and the error become:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7I read that is need put libmysql.dll (32 bit) into :\Qt\5.14.2\mingw73_32\bin
However this not work for me...
-
wrote on 6 May 2020, 23:31 last edited by
Hello! Did you build qsqlmysql.dll yourself?
And if your libmysql.dll is from MySQL Connector/C 6.1, you'll need VS2015 runtime installed on your machine. -
wrote on 7 May 2020, 00:21 last edited by
In QT Creator go to projects on the left side(wrench) and click on it(make sure your in debug). Then under build/build environment add the variable QT_DEBUG_PLUGINS and set it to 1.
Then run again and read the plugin trace and see where it is looking for libmysql.dll and put it there. And make sure you do what @Bonnie said.
--James
-
In QT Creator go to projects on the left side(wrench) and click on it(make sure your in debug). Then under build/build environment add the variable QT_DEBUG_PLUGINS and set it to 1.
Then run again and read the plugin trace and see where it is looking for libmysql.dll and put it there. And make sure you do what @Bonnie said.
--James
wrote on 7 May 2020, 04:39 last edited by Ketan__Patel__0011 5 Jul 2020, 04:42What is your qt version or which toolkit you are using ?
And which mysql version you are using ? -
wrote on 7 May 2020, 05:57 last edited by
-
wrote on 7 May 2020, 08:11 last edited by Thombou 5 Jul 2020, 10:36
Can you open your
qsqlmysql.dll
andlibmysql.dll
with the dependancy walker to make sure all dependancies are found? In my case the libmysql.dll needed 2 additional dlls (I took it from the MySql Server 8.0).If you built the driver yourself and installed is according to the documentation (not only compiling), you should not need to copy the
qsqlmysql.dll
file to the folder \Qt\5.14.2\mingw73_32\plugins\sqldrivers. It should be done during the installation, if I am not wrong. -
wrote on 7 May 2020, 09:04 last edited by
I had brutally copied qsqlmysql.dll into sqldriver.
I just built the plugin as explained here (https://doc.qt.io/qt-5/sql-driver.html) and it works perfectly.Thank you all
-
What is your qt version or which toolkit you are using ?
And which mysql version you are using ?wrote on 7 May 2020, 10:19 last edited by@Ketan__Patel__0011 What is your qt version or which toolkit you are using ?
And which mysql version you are using ?I am using 5.9.9 and I do not have mysql(connecting to a remote server), I just downloaded the connector 6.1 I think that has the libs already built.
--James
-
@Ketan__Patel__0011 What is your qt version or which toolkit you are using ?
And which mysql version you are using ?I am using 5.9.9 and I do not have mysql(connecting to a remote server), I just downloaded the connector 6.1 I think that has the libs already built.
--James
wrote on 7 May 2020, 10:25 last edited by Ketan__Patel__0011 5 Jul 2020, 10:29Copy libmysql.dll into your <QTDIR>bin
Copy libmysql.dll into this Path : C:\Windows\System32
Copy libmysql.dll into this Path : C:\WindowsSet The Environment Variable PATH :
C:\Program Files\MySQL\MySQL Server 5.6\include
C:\Program Files\MySQL\MySQL Server 5.6\lib
-
Hello! Did you build qsqlmysql.dll yourself?
And if your libmysql.dll is from MySQL Connector/C 6.1, you'll need VS2015 runtime installed on your machine.wrote on 7 May 2020, 15:06 last edited by@Bonnie About the deployment I put libmysql.dll (from MySQL Connector / C 6.1) in the folder containing the exe. Does VS2015 runtime need to be installed on each device? To avoid this, can I take the library from other sources?
-
@Bonnie About the deployment I put libmysql.dll (from MySQL Connector / C 6.1) in the folder containing the exe. Does VS2015 runtime need to be installed on each device? To avoid this, can I take the library from other sources?
wrote on 7 May 2020, 16:58 last edited by Bonnie 5 Jul 2020, 17:50@AndreaCT Yes, you can use older versions that has no dependency on VS runtimes. Just check the dll with dependency walker.
EDITED
Actually as I checked, VS runtimes are necessary since 6.1.10.
I think you can try MySQL Connector/C version 6.1.9 or 6.1.6 -
wrote on 7 May 2020, 20:18 last edited by
Perfect, thank you very much
2/12