I had complied qsqlmysql.dll.
-
@jsulm the unreadable characters is what I use qDebug output chineses,I had delete it.
now
mycodeqDebug() << QSqlDatabase::drivers(); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setPort(3306); db.setDatabaseName("mydb"); db.setUserName("root"); db.setPassword("123456"); bool ok = db.open();
the console
16:45:13: Debugging D:\1a_perfect\build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug\debug\testsql.exe ... qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.3.0/mingw_64/plugins/platforms" ... qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/platforms/qdirect2d.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/platforms/qdirect2d.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "direct2d" ] }, "archlevel": 2, "className": "QWindowsDirect2DIntegrationPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("direct2d") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/platforms/qminimal.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/platforms/qminimal.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "minimal" ] }, "archlevel": 2, "className": "QMinimalIntegrationPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimal") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/platforms/qoffscreen.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/platforms/qoffscreen.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "offscreen" ] }, "archlevel": 2, "className": "QOffscreenIntegrationPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("offscreen") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/platforms/qwindows.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/platforms/qwindows.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "windows" ] }, "archlevel": 2, "className": "QWindowsIntegrationPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("windows") qt.core.plugin.factoryloader: checking directory path "D:/1a_perfect/build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug/debug/platforms" ... qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/platforms/qwindows.dll" loaded library qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.3.0/mingw_64/plugins/platformthemes" ... qt.core.plugin.factoryloader: checking directory path "D:/1a_perfect/build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug/debug/platformthemes" ... qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.3.0/mingw_64/plugins/styles" ... qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/styles/qwindowsvistastyle.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/styles/qwindowsvistastyle.dll, metadata= { "IID": "org.qt-project.Qt.QStyleFactoryInterface", "MetaData": { "Keys": [ "windowsvista" ] }, "archlevel": 2, "className": "QWindowsVistaStylePlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("windowsvista") qt.core.plugin.factoryloader: checking directory path "D:/1a_perfect/build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug/debug/styles" ... qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/styles/qwindowsvistastyle.dll" loaded library qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.3.0/mingw_64/plugins/iconengines" ... qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/iconengines/qsvgicon.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/iconengines/qsvgicon.dll, metadata= { "IID": "org.qt-project.Qt.QIconEngineFactoryInterface", "MetaData": { "Keys": [ "svg", "svgz", "svg.gz" ] }, "archlevel": 2, "className": "QSvgIconPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("svg", "svgz", "svg.gz") qt.core.plugin.factoryloader: checking directory path "D:/1a_perfect/build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug/debug/iconengines" ... qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.3.0/mingw_64/plugins/imageformats" ... qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/imageformats/qgif.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/imageformats/qgif.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "gif" ], "MimeTypes": [ "image/gif" ] }, "archlevel": 2, "className": "QGifPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("gif") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/imageformats/qico.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/imageformats/qico.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "ico", "cur" ], "MimeTypes": [ "image/vnd.microsoft.icon", "image/vnd.microsoft.icon" ] }, "archlevel": 2, "className": "QICOPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("ico", "cur") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/imageformats/qjpeg.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/imageformats/qjpeg.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "jpg", "jpeg" ], "MimeTypes": [ "image/jpeg", "image/jpeg" ] }, "archlevel": 2, "className": "QJpegPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("jpg", "jpeg") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/imageformats/qsvg.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/imageformats/qsvg.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "svg", "svgz" ], "MimeTypes": [ "image/svg+xml", "image/svg+xml-compressed" ] }, "archlevel": 2, "className": "QSvgPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("svg", "svgz") qt.core.plugin.factoryloader: checking directory path "D:/1a_perfect/build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug/debug/imageformats" ... qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/imageformats/qgif.dll" loaded library qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/imageformats/qico.dll" loaded library qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/imageformats/qjpeg.dll" loaded library qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/imageformats/qsvg.dll" loaded library qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers" ... qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlite.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlite.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QSQLITE" ] }, "archlevel": 2, "className": "QSQLiteDriverPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlmysql.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlmysql.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL", "QMARIADB" ] }, "archlevel": 2, "className": "QMYSQLDriverPlugin", "debug": true, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlodbc.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlodbc.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QODBC" ] }, "archlevel": 2, "className": "QODBCDriverPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QODBC") qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlpsql.dll" qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlpsql.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL" ] }, "archlevel": 2, "className": "QPSQLDriverPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL") qt.core.plugin.factoryloader: checking directory path "D:/1a_perfect/build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug/debug/sqldrivers" ... QList("QSQLITE", "QMARIADB", "QMYSQL", "QODBC", "QPSQL") qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlmysql.dll" loaded library qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.3.0/mingw_64/plugins/accessible" ... qt.core.plugin.factoryloader: checking directory path "D:/1a_perfect/build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug/debug/accessible" ... qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.3.0/mingw_64/plugins/accessiblebridge" ... qt.core.plugin.factoryloader: checking directory path "D:/1a_perfect/build-testsql-Desktop_Qt_6_3_0_MinGW_64_bit-Debug/debug/accessiblebridge" ...
-
@yuyu said in I had complied qsqlmysql.dll.:
qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlmysql.dll" loaded library
Looks good now
-
@yuyu What does db.open() return?
What does https://doc.qt.io/qt-5/qsqldatabase.html#lastError return after open() call? -
@Nevez yes,but I had install it. it return false.
sometime has
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\\Qt\\6.3.0\\mingw_64\\plugins\\sqldrivers\\qsqlmysql.dll:
-
@yuyu I'm confused: before you posted output showing that the plug-in was loaded.
Now you posted output showing that it could not be loaded.Please do again what was suggested before: set QT_DEBUG_PLUGINS and if the plug-in fails to load post the output here...
-
@yuyu
I am using Mysql 8.x.x and QT 6.2.3. Mysql works fine too.
According to the error you get, you may have placed the relevant DLL in the wrong place or you may have used the wrong version DLL.
There was a video on youtube that did this well. You will find it on your first search. -
@Nevez said in I had complied qsqlmysql.dll.:
I am using Mysql 8.x.x and QT 6.2.3. Mysql works fine too.
According to the error you get, you may have placed the relevant DLL in the wrong place or you may have used the wrong version DLL.
There was a video on youtube that did this well. You will find it on your first search.I user mysql >8.0.19,I see the doc, tha say