Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSqlDatabase: QMYSQL driver not loaded



  • I've been developing and running from within Qt Creator version 4.4.1, with Qt 5.9.2, everything is ok within Qt Creator, I have used windeployqt.exe which created an install folder, I've copied my release executable into this folder, but when I try and run from a command prompt the application starts then displays:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    

    I launch the application with exactly the same command line parameters that I do when running within Qt Creator. What do I need to do in order for it to find the QMYSQL driver?



  • @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    how?

    is libmysql.dll (which is the mysql connector/c DLL) available in your installation?


  • Lifetime Qt Champion

    @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    What do I need to do in order for it to find the QMYSQL driver?

    Search in the forum - this is asked again and again and again.
    Set QT_DEBUG_PLUGINS before starting your app and check output (https://doc.qt.io/qt-5/debug.html).



  • @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    I launch the application with exactly the same command line parameters that I do when running within Qt Creator. What do I need to do in order for it to find the QMYSQL driver?

    Have you verified that the mysql c/c++ connector shared library is provided with your installer?



  • Check if your path points to your bin and lib directories of your MySQL installation.


  • Lifetime Qt Champion

    @ollarch said in QSqlDatabase: QMYSQL driver not loaded:

    MySQL installation

    This is not relevant here, as it is about deployed application which should contain everything needed (including MySQL client driver lib).



  • @KroMignon, how?



  • @jsulm , in the .\install\sqldrivers\ there is qsqlmysql.dll


  • Lifetime Qt Champion

    @SPlatten I'm talking about MySQL client driver, not the Qt MySQL plug-in.
    Please do what I suggested, this will save us time guessing what the problem could be...



  • @jsulm , I now see:

    Cannot load library C:\Users\simon.platten\Documents\install\sqldrivers\qsqlmysql.dll: The specified module could not be found.
    

    How do I get the deployment tool to add the mysql connector/c 6.1 if that is whats required?


  • Lifetime Qt Champion

    @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    I now see

    Is there something above this error? Usually the problem is not qsqlmysql.dll but missing MySQL client library which is used by qsqlmysql.dll. Please post the whole output.



  • @jsulm , thank you, here is the full output:

    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/simon.platten/Documents/install/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/platforms/qwindows.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/platforms/qwindows.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "windows"
            ]
        },
        "className": "QWindowsIntegrationPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("windows")
    loaded library "C:/Users/simon.platten/Documents/install/platforms/qwindows.dll"
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/simon.platten/Documents/install/platformthemes" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/simon.platten/Documents/install/styles" ...
    Chelton - Training Server
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/simon.platten/Documents/install/imageformats" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qgif.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qgif.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "gif"
            ],
            "MimeTypes": [
               "image/gif"
            ]
        },
        "className": "QGifPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("gif")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qicns.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qicns.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "icns"
            ],
            "MimeTypes": [
                "image/x-icns"
            ]
        },
        "className": "QICNSPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("icns")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qico.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qico.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "ico",
                "cur"
            ],
            "MimeTypes": [
                "image/vnd.microsoft.icon"
            ]
        },
        "className": "QICOPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("ico", "cur")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qjpeg.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qjpeg.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "jpg",
                "jpeg"
            ],
            "MimeTypes": [
                "image/jpeg",
                "image/jpeg"
            ]
        },
        "className": "QJpegPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("jpg", "jpeg")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qsvg.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qsvg.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "svg",
                "svgz"
            ],
            "MimeTypes": [
                "image/svg+xml",
                "image/svg+xml-compressed"
            ]
        },
        "className": "QSvgPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("svg", "svgz")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qtga.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qtga.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "tga"
            ],
            "MimeTypes": [
                "image/x-tga"
            ]
        },
        "className": "QTgaPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("tga")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qtiff.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qtiff.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "tiff",
                "tif"
            ],
            "MimeTypes": [
                "image/tiff",
                "image/tiff"
            ]
        },
        "className": "QTiffPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("tiff", "tif")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qwbmp.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qwbmp.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "wbmp"
            ],
            "MimeTypes": [
                "image/vnd.wap.wbmp"
            ]
        },
        "className": "QWbmpPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("wbmp")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/imageformats/qwebp.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/imageformats/qwebp.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
        "MetaData": {
            "Keys": [
                "webp"
            ],
            "MimeTypes": [
                "image/webp"
            ]
        },
        "className": "QWebpPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("webp")
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qgif.dll"
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qicns.dll"
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qico.dll"
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qjpeg.dll"
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qsvg.dll"
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qtga.dll"
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qtiff.dll"
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qwbmp.dll"
    loaded library "C:/Users/simon.platten/Documents/install/imageformats/qwebp.dll"
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/simon.platten/Documents/install/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/simon.platten/Documents/install/sqldrivers" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/sqldrivers/qsqlite.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/sqldrivers/qsqlite.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
                "QSQLITE"
            ]
        },
        "className": "QSQLiteDriverPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("QSQLITE")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/sqldrivers/qsqlmysql.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/sqldrivers/qsqlmysql.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
                "QMYSQL3",
                "QMYSQL"
            ]
        },
        "className": "QMYSQLDriverPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/sqldrivers/qsqlodbc.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/sqldrivers/qsqlodbc.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
                "QODBC3",
                "QODBC"
            ]
        },
        "className": "QODBCDriverPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("QODBC3", "QODBC")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/simon.platten/Documents/install/sqldrivers/qsqlpsql.dll"
    Found metadata in lib C:/Users/simon.platten/Documents/install/sqldrivers/qsqlpsql.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
                "QPSQL7",
                "QPSQL"
            ]
        },
        "className": "QPSQLDriverPlugin",
        "debug": false,
        "version": 329986
    }
     
     
    Got keys from plugin meta data ("QPSQL7", "QPSQL")
    Cannot load library C:\Users\simon.platten\Documents\install\sqldrivers\qsqlmysql.dll: The specified module could not be found.
    QLibraryPrivate::loadPlugin failed on "C:/Users/simon.platten/Documents/install/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\\Users\\simon.platten\\Documents\\install\\sqldrivers\\qsqlmysql.dll: The specified module could not be found."
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/simon.platten/Documents/install/accessiblebridge" ...
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qgif.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qicns.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qico.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qjpeg.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qsvg.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qtga.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qtiff.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qwbmp.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/imageformats/qwebp.dll"
    QLibraryPrivate::unload succeeded on "C:/Users/simon.platten/Documents/install/platforms/qwindows.dll"
    

  • Lifetime Qt Champion

    @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    C:\Users\simon.platten\Documents\install\sqldrivers\qsqlmysql.dll

    Does it exist?



  • @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    how?

    is libmysql.dll (which is the mysql connector/c DLL) available in your installation?



  • @jsulm , yes, it's 100% there.


  • Lifetime Qt Champion

    @SPlatten Then probably libmysql.dll is missing



  • @KroMignon I don't see it, but how on the same system does it work in Qt Creator?

    I found libmariadb.dll in **C:\Program Files (x86)\MariaDB 10.5\lib\**, should I copy that to the install folder?

    Just tried that, still same problem.


  • Lifetime Qt Champion

    @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    but how on the same system does it work in Qt Creator?

    QtCreator prepares the environment before it starts your app.



  • @jsulm , please see edited reply to @KroMignon...

    Now its working, found libmysql.dll in C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib copied to install folder, now it works!

    Thank you for your help!


  • Lifetime Qt Champion

    @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    should I copy that to the install folder?

    Put it next to qsqlmysql.dll (in C:\Users\simon.platten\Documents\install\sqldrivers)



  • @SPlatten said in QSqlDatabase: QMYSQL driver not loaded:

    I don't see it, but how on the same system does it work in Qt Creator? I found libmariadb.dll in **C:\Program Files (x86)\MariaDB 10.5\lib**, should I copy that to the install folder?

    Perhaps the easiest way would be to use dependency walker to see which DLL are required for your mysql plugin sqldrivers/qsqlmysql.dll

    I don't know how you have build the plugin.
    You could try to copy the DLL into the plugin path, so it will be reachable. But be sure it is the right one!


Log in to reply