QMYSQL driver not loaded Error
-
Re: QSqlDatabase: QMYSQL driver not loaded available drivers: QMYSQL
I have the same problem.
I read the question and answers in many topics that had my problem but couldn't solve my problem.
I use Qt 5.9.6 mingw32 and 64 bit windows,i have MySql 5.7 installed.
I don't know how to build the drivers myself(if it is necessary).
here is my system path:C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common; %SystemRoot%\system32; %SystemRoot%;%SystemRoot%\System32\Wbem; %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; C:\Program Files\Microsoft SQL Server\120\DTS\Binn\; C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\; C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\; C:\Program Files\Microsoft SQL Server\120\Tools\Binn\; C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\; C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\; C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin; C:\Strawberry\perl\bin; C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\; C:\Program Files\IVI Foundation\VISA\Win64\Bin\; C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin; C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\; C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\my code has only one line:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");and I have added qt += sql in my .pro file
-
Do you have mysql plugin under plugins/sqldriver directory ?
-
Do you have mysql plugin under plugins/sqldriver directory ?
@dheerendra said in QMYSQL driver not loaded Error:
Do you have mysql plugin under plugins/sqldriver directory ?
is it a *.dll file?if yes , No thereis not any *.dll file in that directory
-
I Found this answer on web:
When you download Qt you have also the source that are provided with it. In my case, it is in : C:\Qt\5.9\Src\qtbase\src\plugins\sqldrivers\mysql Here you have a *.pro (that is a kind of makefile generator). You just have to open it with QtCreator, Compile it and you will get a dll. This dll is the MySQL driver and must be in the same dirent of your application.but when i want to compile the file I receive this error:
Library 'mysql' is not defined. -
i want to build the driver myself using this command:
cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt" nmake sub-mysqlmy MySQL folder location is : C:\Program Files\MySQL
so i use this code:
qmake -- MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"
but I Receive this error:library mysql not defined -
i want to build the driver myself using this command:
cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt" nmake sub-mysqlmy MySQL folder location is : C:\Program Files\MySQL
so i use this code:
qmake -- MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"
but I Receive this error:library mysql not defined@rezaMSLM
Because your folder name has spaces in it, when you changed the command line you don't seem to have done the necessary quoting? Does the following work better:qmake -- "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"Otherwise, although it may be OK, you are mixing
\s and/s in your version, is that an issue? -
@rezaMSLM
Because your folder name has spaces in it, when you changed the command line you don't seem to have done the necessary quoting? Does the following work better:qmake -- "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"Otherwise, although it may be OK, you are mixing
\s and/s in your version, is that an issue?@JonB said in QMYSQL driver not loaded Error:
@rezaMSLM
Because your folder name has spaces in it, when you changed the command line you don't seem to have done the necessary quoting? Does the following work better:qmake -- "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"Otherwise, although it may be OK, you are mixing
\s and/s in your version, is that an issue?I Tried both
qmake -- MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"and
qmake -- "MYSQL_INCDIR=C:/Program Files/MySQL/MySQL Server 5.7/include" "MYSQL_LIBDIR=C:/Program Files/MySQL/MySQL Server 5.7/lib/opt"but receive the same error:
D:\Qt\Qt5.9.6\5.9.6\Src\qtbase\src\plugins\sqldrivers\qtsqldrivers-config.pri: the system cannot find the file specified. project ERROR: Library 'mysql' is not defined.EDIT:
I have no folder named "opt" in "C:/Program Files/MySQL/MySQL Server 5.7/lib"
my mysql.h file is inC:\Program Files\MySQL\MySQL Server 5.7\includeand libmysql.lib is in
C:\Program Files\MySQL\MySQL Server 5.7\libso I used this code:
qmake -- "MYSQL_INCDIR=C:/Program Files/MySQL/MySQL Server 5.7/include" "MYSQL_LIBDIR=C:/Program Files/MySQL/MySQL Server 5.7/lib"but have the same error
-
For people that have this Problem:
this solved my problem