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

mysql connection error



  • i have searched alot on the web for solving but with no luck

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

    db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("127.0.0.1");
    db.setPort(3306);
    db.setUserName("root");
    db.setPassword("123456");
    db.setDatabaseName("test");
    qDebug() << db.open();

  • Lifetime Qt Champion

    Hi,

    This question has been asked many times already on this forum with always the same starting point:

    What version of Qt are you using ?
    On what platform ?
    What version of MySQL ?
    Did you install the MySQL client libraries ?



  • @SGaist
    EDITED

    1. qt 5.11.0
    2. windows
    3. 8.0.13
    4. yes i have

    i managed load it using mysql c connector lib
    but when i deploy the project it doesn't connect


  • Lifetime Qt Champion

    Do you have the MySQL dlls findable by your application ?



  • @SGaist
    i don't know


  • Lifetime Qt Champion

    Then go to the Run part of the Project panel and add the QT_DEBUG_PLUGINS environment variable. Set it to 1 and look at your application for more information about what is happening.



  • @SGaist
    thats the output

    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qminimal.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qminimal.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
       "MetaData": {
           "Keys": [
               "minimal"
           ]
       },
       "className": "QMinimalIntegrationPlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qminimal.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qminimald.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qminimald.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
       "MetaData": {
           "Keys": [
               "minimal"
           ]
       },
       "className": "QMinimalIntegrationPlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qoffscreen.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qoffscreen.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
       "MetaData": {
           "Keys": [
               "offscreen"
           ]
       },
       "className": "QOffscreenIntegrationPlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qoffscreen.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qoffscreend.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qoffscreend.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
       "MetaData": {
           "Keys": [
               "offscreen"
           ]
       },
       "className": "QOffscreenIntegrationPlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qwindows.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qwindows.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
       "MetaData": {
           "Keys": [
               "windows"
           ]
       },
       "className": "QWindowsIntegrationPlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qwindows.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qwindowsd.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qwindowsd.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
       "MetaData": {
           "Keys": [
               "windows"
           ]
       },
       "className": "QWindowsIntegrationPlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("windows")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/David/Documents/build-untitled-Desktop_Qt_5_11_0_MinGW_32bit-Debug/debug/platforms" ...
    loaded library "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qwindowsd.dll"
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platformthemes" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platformthemes/qflatpak.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platformthemes/qflatpak.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
       "MetaData": {
           "Keys": [
               "flatpak"
           ]
       },
       "className": "QFlatpakThemePlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platformthemes/qflatpak.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platformthemes/qflatpakd.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platformthemes/qflatpakd.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
       "MetaData": {
           "Keys": [
               "flatpak"
           ]
       },
       "className": "QFlatpakThemePlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("flatpak")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/David/Documents/build-untitled-Desktop_Qt_5_11_0_MinGW_32bit-Debug/debug/platformthemes" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/styles" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/styles/qwindowsvistastyle.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/styles/qwindowsvistastyle.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QStyleFactoryInterface",
       "MetaData": {
           "Keys": [
               "windowsvista"
           ]
       },
       "className": "QWindowsVistaStylePlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/styles/qwindowsvistastyle.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/styles/qwindowsvistastyled.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/styles/qwindowsvistastyled.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QStyleFactoryInterface",
       "MetaData": {
           "Keys": [
               "windowsvista"
           ]
       },
       "className": "QWindowsVistaStylePlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("windowsvista")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/David/Documents/build-untitled-Desktop_Qt_5_11_0_MinGW_32bit-Debug/debug/styles" ...
    loaded library "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/styles/qwindowsvistastyled.dll"
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/iconengines" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/iconengines/qsvgicon.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/iconengines/qsvgicon.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
       "MetaData": {
           "Keys": [
               "svg",
               "svgz",
               "svg.gz"
           ]
       },
       "className": "QSvgIconPlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/iconengines/qsvgicon.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/iconengines/qsvgicond.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/iconengines/qsvgicond.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
       "MetaData": {
           "Keys": [
               "svg",
               "svgz",
               "svg.gz"
           ]
       },
       "className": "QSvgIconPlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("svg", "svgz", "svg.gz")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/David/Documents/build-untitled-Desktop_Qt_5_11_0_MinGW_32bit-Debug/debug/iconengines" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlite.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlite.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
       "MetaData": {
           "Keys": [
               "QSQLITE"
           ]
       },
       "className": "QSQLiteDriverPlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlite.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlited.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlited.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
       "MetaData": {
           "Keys": [
               "QSQLITE"
           ]
       },
       "className": "QSQLiteDriverPlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("QSQLITE")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlmysql.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlmysql.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
       "MetaData": {
           "Keys": [
               "QMYSQL3",
               "QMYSQL"
           ]
       },
       "className": "QMYSQLDriverPlugin",
       "debug": false,
       "version": 330496
    }
    
    
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlmysqld.dll"
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlmysqld.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlmysqld.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
       "MetaData": {
           "Keys": [
               "QMYSQL3",
               "QMYSQL"
           ]
       },
       "className": "QMYSQLDriverPlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlodbc.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlodbc.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
       "MetaData": {
           "Keys": [
               "QODBC3",
               "QODBC"
           ]
       },
       "className": "QODBCDriverPlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlodbc.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlodbcd.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlodbcd.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
       "MetaData": {
           "Keys": [
               "QODBC3",
               "QODBC"
           ]
       },
       "className": "QODBCDriverPlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("QODBC3", "QODBC")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlpsql.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlpsql.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
       "MetaData": {
           "Keys": [
               "QPSQL7",
               "QPSQL"
           ]
       },
       "className": "QPSQLDriverPlugin",
       "debug": false,
       "version": 330496
    }
    
    
    "The plugin 'C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlpsql.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
            not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlpsqld.dll"
    Found metadata in lib C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlpsqld.dll, metadata=
    {
       "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
       "MetaData": {
           "Keys": [
               "QPSQL7",
               "QPSQL"
           ]
       },
       "className": "QPSQLDriverPlugin",
       "debug": true,
       "version": 330496
    }
    
    
    Got keys from plugin meta data ("QPSQL7", "QPSQL")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/David/Documents/build-untitled-Desktop_Qt_5_11_0_MinGW_32bit-Debug/debug/sqldrivers" ...
    loaded library "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlmysqld.dll"
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/David/Documents/build-untitled-Desktop_Qt_5_11_0_MinGW_32bit-Debug/debug/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/accessiblebridge" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/David/Documents/build-untitled-Desktop_Qt_5_11_0_MinGW_32bit-Debug/debug/accessiblebridge" ...
    QLibraryPrivate::unload succeeded on "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/styles/qwindowsvistastyled.dll" 
    QLibraryPrivate::unload succeeded on "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/platforms/qwindowsd.dll" 
    QLibraryPrivate::unload succeeded on "C:/Qt/Qt5.11.0/5.11.0/mingw53_32/plugins/sqldrivers/qsqlmysqld.dll
    ```"

  • Lifetime Qt Champion

    Since you marked the thread solved, what did you do to fix the situation ?


Log in to reply