Solved MySql Driver not loaded , Note: i tried all the existed forums problems and didn't work
-
@MostafaEzzat I don't see it trying to load any SQL drivers. Do you have anything in plugins/sqldrivers directory of your Qt installation?
By the way: it should NOT search in qtbase/src/plugins/sqldrivers as that is source code directory, it should search in D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers
-
i copied qsqlmysql4.dll into D:\Qt\5.15.1\mingw81_32\plugins\sqldrivers
and i got this
should i copy qtbase/src/plugins/sqldrivers into D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers files into
Got keys from plugin meta data ("QODBC3", "QODBC") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers/qsqlpsql.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers/qsqlpsql.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL7", "QPSQL" ] }, "archreq": 0, "className": "QPSQLDriverPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/sqldrivers" ... ("QSQLITE", "QMARIADB", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7") Cannot load library D:\Qt\5.15.1\mingw81_32\plugins\sqldrivers\qsqlmysql.dll: Unknown error 0x000000c1. QLibraryPrivate::loadPlugin failed on "D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library D:\\Qt\\5.15.1\\mingw81_32\\plugins\\sqldrivers\\qsqlmysql.dll: Unknown error 0x000000c1." QSqlDatabase: QMARIADB driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 Donnne "Driver not loaded Driver not loaded" not Connected QSqlQuery::exec: database not open
-
@MostafaEzzat said in MySql Driver not loaded , Note: i tried all the existed forums problems and didn't work:
i copied qsqlmysql4.dll
From where?
-
neither QMARIADB nor QMYSQL both don't load
and i copied it from qtbase/src/plugins/sqldrivers
the path where i usedD:\Qt\5.15.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:\Program Files (x86)\MariaDB 10.0\include\mysql" MYSQL_LIBDIR="C:\Program Files (x86)\MariaDB 10.0\lib"
-
@MostafaEzzat It still looks like you DO not follow the documentation (https://doc.qt.io/qt-5/sql-driver.html#building-the-drivers): after building you need to do "make install", that will copy the DLLs to your Qt installation.
Also, are you sure you used the correct qmake to build the plug-ins? I'm asking because you used qmake without absolute path. -
@jsulm said in MySql Driver not loaded , Note: i tried all the existed forums problems and didn't work:
I'm asking because you used qmake without absolute path.
And because the plugin name is wrong - the '4' looks suspicious.
-
i did use
mingw32-make sub-mysql then mingw32-make install
but i'm not sure i use the right path because i was running this software on linux before
but this my .pro file
should i change the path from .pro file or options#------------------------------------------------- # # Project created by QtCreator 2018-12-24T22:54:39 # #------------------------------------------------- # QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets designer TARGET = Hospital-ClinicSoftware TEMPLATE += app lib libs # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += c++11 designer plugins plugin SOURCES += \ main.cpp \ mainwindow.cpp \ mainprocess.cpp \ mysqldatabase.cpp \ showingdata.cpp \ delgate.cpp \ profile3.cpp \ profile.cpp \ multipagewidget.cpp \ multipagewidgetplugin.cpp \ multipagewidgetcontainerextension.cpp \ multipagewidgetextensionfactory.cpp \ mysqldatabase.cpp HEADERS += \ mainwindow.h \ mainprocess.h \ showingdata.h \ delgate.h \ profile3.h \ profile.h \ multipagewidget.h \ multipagewidgetplugin.h \ multipagewidgetcontainerextension.h \ multipagewidgetextensionfactory.h \ mysqldatabase.h FORMS += \ mainwindow.ui \ mainprocess.ui \ showingdata.ui \ profile3.ui \ profile.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path += /opt/$${TARGET}/bin $$[QT_INSTALL_PLUGINS]/designer !isEmpty(target.path): INSTALLS += target
-
@MostafaEzzat You should call qmake using whole path to make sure you use the one from the Qt version you're building for.
-
such a weird thing , i didn't know that i should copy libmysql.dll to D:\Qt\5.15.1\mingw81_32\plugins\sqldrivers
i only copied to mingw81_32/bin
now it's working
Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/sqldrivers" ... ("QSQLITE", "QMARIADB", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7") loaded library "D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers/qsqlmysql.dll" Donnne Connected
Thank you guys i do love this community
-
@MostafaEzzat Yes, plug-ins are somewhat special: they are expected to be in a specific location and are loaded at runtime.