Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QSqlDatabase: QMYSQL driver not loaded
Forum Updated to NodeBB v4.3 + New Features

QSqlDatabase: QMYSQL driver not loaded

Scheduled Pinned Locked Moved Unsolved Qt 6
33 Posts 5 Posters 6.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlexFr
    wrote on last edited by AlexFr
    #1

    I am currently using Qt 6.4.0 and when I run this code...

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("xxx.x.x.x");
    db.setDatabaseName("databaseName");
    db.setUserName("userName");
    db.setPassword("password");
    bool ok = db.open();
    if(ok)
    {
    qDebug() << "Database connection";
    }
    else
    {
    qDebug() << "No Connection";
    }

    return a.exec();
    

    }

    I get the following error:
    "
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QPSQL
    No Connection
    "
    Can anyone solve please guide through the process of solving this error? I already tried many proposed solutions on other threads in this forum, and also tried some suggestions from stackoverflow. Nothing has however worked so far.

    I look forward to getting some help here . thanks in advance.

    JonBJ 1 Reply Last reply
    0
    • A AlexFr

      I am currently using Qt 6.4.0 and when I run this code...

      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
      db.setHostName("xxx.x.x.x");
      db.setDatabaseName("databaseName");
      db.setUserName("userName");
      db.setPassword("password");
      bool ok = db.open();
      if(ok)
      {
      qDebug() << "Database connection";
      }
      else
      {
      qDebug() << "No Connection";
      }

      return a.exec();
      

      }

      I get the following error:
      "
      QSqlDatabase: QMYSQL driver not loaded
      QSqlDatabase: available drivers: QSQLITE QODBC QPSQL
      No Connection
      "
      Can anyone solve please guide through the process of solving this error? I already tried many proposed solutions on other threads in this forum, and also tried some suggestions from stackoverflow. Nothing has however worked so far.

      I look forward to getting some help here . thanks in advance.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @AlexFr said in QSqlDatabase: QMYSQL driver not loaded:

      I already tried many proposed solutions on other threads in this forum, and also tried some suggestions from stackoverflow.

      Hello and welcome.

      So the most important is to start by setting environment variable QT_DEBUG_PLUGINS=1 and then run your program. Look at the end of the diagnostic output to find what the cause of the problem is.

      A 1 Reply Last reply
      0
      • A Offline
        A Offline
        AlexFr
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • JonBJ JonB

          @AlexFr said in QSqlDatabase: QMYSQL driver not loaded:

          I already tried many proposed solutions on other threads in this forum, and also tried some suggestions from stackoverflow.

          Hello and welcome.

          So the most important is to start by setting environment variable QT_DEBUG_PLUGINS=1 and then run your program. Look at the end of the diagnostic output to find what the cause of the problem is.

          A Offline
          A Offline
          AlexFr
          wrote on last edited by
          #4

          @JonB 19:24:32: Starting C:\Users\Nelson\Documents\CP\build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug\debug\DatabaseConn.exe...
          qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.4.0/msvc2019_64/plugins/platforms" ...
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qdirect2d.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qdirect2d.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
          "Keys": [
          "direct2d"
          ]
          },
          "archlevel": 1,
          "className": "QWindowsDirect2DIntegrationPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: "The plugin 'C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qdirect2d.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
          not a plugin
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qdirect2dd.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qdirect2dd.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
          "Keys": [
          "direct2d"
          ]
          },
          "archlevel": 1,
          "className": "QWindowsDirect2DIntegrationPlugin",
          "debug": true,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("direct2d")
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qminimal.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qminimal.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
          "Keys": [
          "minimal"
          ]
          },
          "archlevel": 0,
          "className": "QMinimalIntegrationPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: "The plugin 'C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qminimal.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
          not a plugin
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qminimald.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qminimald.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
          "Keys": [
          "minimal"
          ]
          },
          "archlevel": 0,
          "className": "QMinimalIntegrationPlugin",
          "debug": true,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimal")
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qoffscreen.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qoffscreen.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
          "Keys": [
          "offscreen"
          ]
          },
          "archlevel": 0,
          "className": "QOffscreenIntegrationPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: "The plugin 'C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qoffscreen.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
          not a plugin
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qoffscreend.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qoffscreend.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
          "Keys": [
          "offscreen"
          ]
          },
          "archlevel": 0,
          "className": "QOffscreenIntegrationPlugin",
          "debug": true,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("offscreen")
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qwindows.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qwindows.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
          "Keys": [
          "windows"
          ]
          },
          "archlevel": 0,
          "className": "QWindowsIntegrationPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: "The plugin 'C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qwindows.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
          not a plugin
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qwindowsd.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qwindowsd.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
          "Keys": [
          "windows"
          ]
          },
          "archlevel": 0,
          "className": "QWindowsIntegrationPlugin",
          "debug": true,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("windows")
          qt.core.plugin.factoryloader: checking directory path "C:/Users/Nelson/Documents/CP/build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/debug/platforms" ...
          qt.core.library: "C:/Qt/6.4.0/msvc2019_64/plugins/platforms/qwindowsd.dll" loaded library
          qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.4.0/msvc2019_64/plugins/platformthemes" ...
          qt.core.plugin.factoryloader: checking directory path "C:/Users/Nelson/Documents/CP/build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/debug/platformthemes" ...
          qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.4.0/msvc2019_64/plugins/styles" ...
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/styles/qwindowsvistastyle.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/styles/qwindowsvistastyle.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QStyleFactoryInterface",
          "MetaData": {
          "Keys": [
          "windowsvista"
          ]
          },
          "archlevel": 0,
          "className": "QWindowsVistaStylePlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: "The plugin 'C:/Qt/6.4.0/msvc2019_64/plugins/styles/qwindowsvistastyle.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
          not a plugin
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/styles/qwindowsvistastyled.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/styles/qwindowsvistastyled.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QStyleFactoryInterface",
          "MetaData": {
          "Keys": [
          "windowsvista"
          ]
          },
          "archlevel": 0,
          "className": "QWindowsVistaStylePlugin",
          "debug": true,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("windowsvista")
          qt.core.plugin.factoryloader: checking directory path "C:/Users/Nelson/Documents/CP/build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/debug/styles" ...
          qt.core.library: "C:/Qt/6.4.0/msvc2019_64/plugins/styles/qwindowsvistastyled.dll" loaded library
          qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers" ...
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlite.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlite.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QSQLITE"
          ]
          },
          "archlevel": 0,
          "className": "QSQLiteDriverPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: "The plugin 'C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlite.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
          not a plugin
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlited.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlited.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QSQLITE"
          ]
          },
          "archlevel": 0,
          "className": "QSQLiteDriverPlugin",
          "debug": true,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlodbc.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlodbc.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QODBC"
          ]
          },
          "archlevel": 0,
          "className": "QODBCDriverPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: "The plugin 'C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlodbc.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
          not a plugin
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlodbcd.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlodbcd.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QODBC"
          ]
          },
          "archlevel": 0,
          "className": "QODBCDriverPlugin",
          "debug": true,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QODBC")
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlpsql.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlpsql.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QPSQL"
          ]
          },
          "archlevel": 0,
          "className": "QPSQLDriverPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: "The plugin 'C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlpsql.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
          not a plugin
          qt.core.plugin.factoryloader: looking at "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlpsqld.dll"
          qt.core.plugin.loader: Found metadata in lib C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/qsqlpsqld.dll, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QPSQL"
          ]
          },
          "archlevel": 0,
          "className": "QPSQLDriverPlugin",
          "debug": true,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
          qt.core.plugin.factoryloader: checking directory path "C:/Users/Nelson/Documents/CP/build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/debug/sqldrivers" ...
          QSqlDatabase: QMYSQL driver not loaded
          QSqlDatabase: available drivers: QSQLITE QODBC QPSQL
          No Connection
          qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.4.0/msvc2019_64/plugins/accessiblebridge" ...
          qt.core.plugin.factoryloader: checking directory path "C:/Users/Nelson/Documents/CP/build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/debug/accessiblebridge" ...

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            From the looks of it, you did not build the MySQL plugin and if you did, you did not install it.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              QSqlDatabase: available drivers: QSQLITE QODBC QPSQL

              As you can see there is no MySQL Qt plugin in your Qt installation - so why do you expect that it works?
              You have to compile the MySQL Qt plugin by yourself as properly described in the documentation or use another database which is directly supported.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              A 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                QSqlDatabase: available drivers: QSQLITE QODBC QPSQL

                As you can see there is no MySQL Qt plugin in your Qt installation - so why do you expect that it works?
                You have to compile the MySQL Qt plugin by yourself as properly described in the documentation or use another database which is directly supported.

                A Offline
                A Offline
                AlexFr
                wrote on last edited by
                #7

                @Christian-Ehrlicher thanks. When I try to run the command you suggested, I get this error:
                The ""cmake"" command is either misspelled or
                could not be found.

                Christian EhrlicherC 1 Reply Last reply
                0
                • A AlexFr

                  @Christian-Ehrlicher thanks. When I try to run the command you suggested, I get this error:
                  The ""cmake"" command is either misspelled or
                  could not be found.

                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @AlexFr said in QSqlDatabase: QMYSQL driver not loaded:

                  When I try to run the command you suggested, I get this error:

                  I did not suggest any command.
                  If you want to compile your plugin, you have to make sure that your development environment is properly set up (which also means cmake is available in your PATH).

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  A 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    @AlexFr said in QSqlDatabase: QMYSQL driver not loaded:

                    When I try to run the command you suggested, I get this error:

                    I did not suggest any command.
                    If you want to compile your plugin, you have to make sure that your development environment is properly set up (which also means cmake is available in your PATH).

                    A Offline
                    A Offline
                    AlexFr
                    wrote on last edited by
                    #9

                    @Christian-Ehrlicher thanks for your answer. I compiled the plugin with the command: qt-cmake -G Ninja C:\Qt\6.0.0\Src\qtbase\src\plugins\sqldrivers -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.0.0\mingw81_64"

                    but still nothing has changed. it compiled without errors, but I still get the same error in Qt creator. Please do you have futher ideas regarding this issue I am facing? I am also researching it online.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      As I suggested, did you install the plugin ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      A 3 Replies Last reply
                      0
                      • SGaistS SGaist

                        As I suggested, did you install the plugin ?

                        A Offline
                        A Offline
                        AlexFr
                        wrote on last edited by
                        #11

                        @SGaist I tried, but I get an error. the file "mysql.h" is missing from the <MySQL dir>/include/ directory. I installed MySQL smoothly but somehow that file is missing.

                        1 Reply Last reply
                        0
                        • hskoglundH Offline
                          hskoglundH Offline
                          hskoglund
                          wrote on last edited by
                          #12

                          Hi, please be careful with your versions of Qt:

                          1. you use Qt 5.15.2 for the debug build
                            (C:/Users/Nelson/Documents/CP/build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/debug/)
                          2. 'C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/ as the place where Qt looks for the MySQL plugin
                          3. C:\Qt\6.0.0\Src\qtbase\src\plugins\sqldrivers is where you build it from (and installing to C:\Qt\6.0.0\mingw81_64)

                          Don't know if that's the cause of the problems but it will help to only use one version of Qt for everything :-)

                          A JonBJ 2 Replies Last reply
                          2
                          • SGaistS SGaist

                            As I suggested, did you install the plugin ?

                            A Offline
                            A Offline
                            AlexFr
                            wrote on last edited by
                            #13

                            @SGaist I finally have installed it, but the error persists.

                            "
                            QSqlDatabase: QMYSQL driver not loaded
                            QSqlDatabase: available drivers: QSQLITE QODBC QPSQL
                            "

                            1 Reply Last reply
                            0
                            • hskoglundH hskoglund

                              Hi, please be careful with your versions of Qt:

                              1. you use Qt 5.15.2 for the debug build
                                (C:/Users/Nelson/Documents/CP/build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/debug/)
                              2. 'C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/ as the place where Qt looks for the MySQL plugin
                              3. C:\Qt\6.0.0\Src\qtbase\src\plugins\sqldrivers is where you build it from (and installing to C:\Qt\6.0.0\mingw81_64)

                              Don't know if that's the cause of the problems but it will help to only use one version of Qt for everything :-)

                              A Offline
                              A Offline
                              AlexFr
                              wrote on last edited by
                              #14

                              @hskoglund yeah I fixed that. thanks. but it was not the cause of my woes.

                              1 Reply Last reply
                              0
                              • SGaistS SGaist

                                As I suggested, did you install the plugin ?

                                A Offline
                                A Offline
                                AlexFr
                                wrote on last edited by
                                #15

                                @SGaist the errors I am getting

                                qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
                                qt.core.plugin.factoryloader: checking directory path "C:/Users/user/Documents/CP/build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/debug/sqldrivers" ...
                                QSqlDatabase: QMYSQL driver not loaded
                                QSqlDatabase: available drivers: QSQLITE QODBC QPSQL
                                No Connection

                                qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.4.0/msvc2019_64/plugins/accessiblebridge" ...
                                qt.core.plugin.factoryloader: checking directory path "C:/Users/user/Documents/CP/build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/debug/accessiblebridge" ...

                                any help would be greatly appreciated.

                                JonBJ 1 Reply Last reply
                                0
                                • A AlexFr

                                  @SGaist the errors I am getting

                                  qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
                                  qt.core.plugin.factoryloader: checking directory path "C:/Users/user/Documents/CP/build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/debug/sqldrivers" ...
                                  QSqlDatabase: QMYSQL driver not loaded
                                  QSqlDatabase: available drivers: QSQLITE QODBC QPSQL
                                  No Connection

                                  qt.core.plugin.factoryloader: checking directory path "C:/Qt/6.4.0/msvc2019_64/plugins/accessiblebridge" ...
                                  qt.core.plugin.factoryloader: checking directory path "C:/Users/user/Documents/CP/build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Debug/debug/accessiblebridge" ...

                                  any help would be greatly appreciated.

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by JonB
                                  #16

                                  @AlexFr said in QSqlDatabase: QMYSQL driver not loaded:

                                  QSqlDatabase: QMYSQL driver not loaded
                                  QSqlDatabase: available drivers: QSQLITE QODBC QPSQL

                                  Your output show no sign/mention of finding any QMYSQL plugin anywhere (where it is looking). So what file(s) do you have where for plugins with regard to QMYSQL? It looks like either there is nothing at all, so it cannot even try to load it, or there is some output earlier in the diagnostic relating to QMYSQL which you are not showing.

                                  A 1 Reply Last reply
                                  0
                                  • JonBJ JonB

                                    @AlexFr said in QSqlDatabase: QMYSQL driver not loaded:

                                    QSqlDatabase: QMYSQL driver not loaded
                                    QSqlDatabase: available drivers: QSQLITE QODBC QPSQL

                                    Your output show no sign/mention of finding any QMYSQL plugin anywhere (where it is looking). So what file(s) do you have where for plugins with regard to QMYSQL? It looks like either there is nothing at all, so it cannot even try to load it, or there is some output earlier in the diagnostic relating to QMYSQL which you are not showing.

                                    A Offline
                                    A Offline
                                    AlexFr
                                    wrote on last edited by
                                    #17

                                    @JonB in this folder "C:\Qt\6.4.0\mingw_64\plugins\sqldrivers", I have "qsqlmysql.dll" and "qsqlmysql.debug", amongst other files. I built the plugin using:
                                    "
                                    mkdir build-sqldrivers
                                    cd build-sqldrivers

                                    qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path><platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib"
                                    cmake --build .
                                    cmake --install .
                                    "

                                    1 Reply Last reply
                                    0
                                    • hskoglundH hskoglund

                                      Hi, please be careful with your versions of Qt:

                                      1. you use Qt 5.15.2 for the debug build
                                        (C:/Users/Nelson/Documents/CP/build-DatabaseConn-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/debug/)
                                      2. 'C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/ as the place where Qt looks for the MySQL plugin
                                      3. C:\Qt\6.0.0\Src\qtbase\src\plugins\sqldrivers is where you build it from (and installing to C:\Qt\6.0.0\mingw81_64)

                                      Don't know if that's the cause of the problems but it will help to only use one version of Qt for everything :-)

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on last edited by
                                      #18

                                      @hskoglund said in QSqlDatabase: QMYSQL driver not loaded:

                                      'C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/ as the place where Qt looks for the MySQL plugin
                                      C:\Qt\6.0.0\Src\qtbase\src\plugins\sqldrivers is where you build it from (and installing to C:\Qt\6.0.0\mingw81_64)

                                      @AlexFr said in QSqlDatabase: QMYSQL driver not loaded:

                                      @JonB in this folder "C:\Qt\6.4.0\mingw_64\plugins\sqldrivers", I have "qsqlmysql.dll" and "qsqlmysql.debug"

                                      Seems to me you have a mix-up/mismatch betwenn these paths, not to mention whether you are using MinGW versus MSVC. Sort out what you are using from where, for sure. That is all I know.

                                      A 1 Reply Last reply
                                      0
                                      • JonBJ JonB

                                        @hskoglund said in QSqlDatabase: QMYSQL driver not loaded:

                                        'C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/ as the place where Qt looks for the MySQL plugin
                                        C:\Qt\6.0.0\Src\qtbase\src\plugins\sqldrivers is where you build it from (and installing to C:\Qt\6.0.0\mingw81_64)

                                        @AlexFr said in QSqlDatabase: QMYSQL driver not loaded:

                                        @JonB in this folder "C:\Qt\6.4.0\mingw_64\plugins\sqldrivers", I have "qsqlmysql.dll" and "qsqlmysql.debug"

                                        Seems to me you have a mix-up/mismatch betwenn these paths, not to mention whether you are using MinGW versus MSVC. Sort out what you are using from where, for sure. That is all I know.

                                        A Offline
                                        A Offline
                                        AlexFr
                                        wrote on last edited by
                                        #19

                                        @JonB thanks for the reply. I also have I have "qsqlmysql.dll" and "qsqlmysql.debug" in "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/" and it still does not work.

                                        JonBJ 1 Reply Last reply
                                        0
                                        • A AlexFr

                                          @JonB thanks for the reply. I also have I have "qsqlmysql.dll" and "qsqlmysql.debug" in "C:/Qt/6.4.0/msvc2019_64/plugins/sqldrivers/" and it still does not work.

                                          JonBJ Offline
                                          JonBJ Offline
                                          JonB
                                          wrote on last edited by
                                          #20

                                          @AlexFr
                                          It's no good just having the files in that directory, you have to have the application looking in that directory to find it/them. I do not not know whether that is happening in your situation.

                                          A 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved