Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. I have Mysql plugin installed, but the driver won't load.
Forum Updated to NodeBB v4.3 + New Features

I have Mysql plugin installed, but the driver won't load.

Scheduled Pinned Locked Moved Solved Installation and Deployment
5 Posts 3 Posters 500 Views 1 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.
  • S Offline
    S Offline
    spotted
    wrote on last edited by
    #1

    I've done all of the researching and went through every thread but I cannot get it to work.

    I followed the instructions according to the docs like this for installation:
    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="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
    cmake --build .
    cmake --install .

    I have debugged, it and this is what I am getting:

    09:28:04: Starting /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/DatabaseConnection...
    qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers" ...
    qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib"
    qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QSQLITE"
    ]
    },
    "archlevel": 2,
    "className": "QSQLiteDriverPlugin",
    "debug": false,
    "version": 394240
    }

    qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
    qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib"
    qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QMYSQL",
    "QMARIADB"
    ]
    },
    "archlevel": 2,
    "className": "QMYSQLDriverPlugin",
    "debug": false,
    "version": 394240
    }

    qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
    qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib"
    qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QODBC"
    ]
    },
    "archlevel": 2,
    "className": "QODBCDriverPlugin",
    "debug": false,
    "version": 394240
    }

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

    qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
    qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers" ...
    qt.core.plugin.factoryloader: looking at "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlite.dylib"
    qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlite.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QSQLITE"
    ]
    },
    "archlevel": 2,
    "className": "QSQLiteDriverPlugin",
    "debug": false,
    "version": 394240
    }

    qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
    qt.core.plugin.factoryloader: looking at "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlmysql.dylib"
    qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlmysql.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QMYSQL",
    "QMARIADB"
    ]
    },
    "archlevel": 2,
    "className": "QMYSQLDriverPlugin",
    "debug": false,
    "version": 394240
    }

    qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
    qt.core.plugin.factoryloader: looking at "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlodbc.dylib"
    qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlodbc.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QODBC"
    ]
    },
    "archlevel": 2,
    "className": "QODBCDriverPlugin",
    "debug": false,
    "version": 394240
    }

    qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QODBC")
    qt.core.plugin.factoryloader: looking at "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlpsql.dylib"
    qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlpsql.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QPSQL"
    ]
    },
    "archlevel": 2,
    "className": "QPSQLDriverPlugin",
    "debug": false,
    "version": 394240
    }

    qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
    QSqlDatabase: ForQt driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
    Failed to connect.
    09:28:04: /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/DatabaseConnection exited with code 0

    bolded text The debugging doesn't really tell me what is wrong. Can someone please help me, I spent a lot of time on this already.

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

      Hi, maybe Qt gets confused because it loads twp different Mysql dylibs:
      /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib
      /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlmysql.dylib

      (when I run a similar app and turn on QT_DEBUG_PLUGINS=1 I only see the first dylib)
      What happens if you remove the second one?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        spotted
        wrote on last edited by
        #3

        The files inside of the Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/ were what I placed there myself. I removed the folder and this is the result and also the first original error:

        10:27:06: Starting /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/DatabaseConnection...
        qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers" ...
        qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib"
        qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib, metadata=
        {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
        "Keys": [
        "QSQLITE"
        ]
        },
        "archlevel": 2,
        "className": "QSQLiteDriverPlugin",
        "debug": false,
        "version": 394240
        }

        qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
        qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib"
        qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib, metadata=
        {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
        "Keys": [
        "QMYSQL",
        "QMARIADB"
        ]
        },
        "archlevel": 2,
        "className": "QMYSQLDriverPlugin",
        "debug": false,
        "version": 394240
        }

        qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
        qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib"
        qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
        {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
        "Keys": [
        "QODBC"
        ]
        },
        "archlevel": 2,
        "className": "QODBCDriverPlugin",
        "debug": false,
        "version": 394240
        }

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

        qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
        qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers" ...
        QSqlDatabase: ForQt driver not loaded
        QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
        Failed to connect.
        **10:27:06: /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/**DatabaseConnection exited with code 0

        I saw that it was searching for files in the path " /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/" and there were no sqldrivers there so I copied the sqldrivers folder that were generated when I ran the:
        qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
        cmake --build .
        cmake --install .

        After I copied the folder sqldrivers that were generated inside the plugins/ over to the " /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/" and I got the error in the first post above.

        Christian EhrlicherC 1 Reply Last reply
        0
        • S spotted

          The files inside of the Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/ were what I placed there myself. I removed the folder and this is the result and also the first original error:

          10:27:06: Starting /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/DatabaseConnection...
          qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers" ...
          qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib"
          qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QSQLITE"
          ]
          },
          "archlevel": 2,
          "className": "QSQLiteDriverPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
          qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib"
          qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QMYSQL",
          "QMARIADB"
          ]
          },
          "archlevel": 2,
          "className": "QMYSQLDriverPlugin",
          "debug": false,
          "version": 394240
          }

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
          qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib"
          qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
          {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
          "Keys": [
          "QODBC"
          ]
          },
          "archlevel": 2,
          "className": "QODBCDriverPlugin",
          "debug": false,
          "version": 394240
          }

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

          qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
          qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers" ...
          QSqlDatabase: ForQt driver not loaded
          QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
          Failed to connect.
          **10:27:06: /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/**DatabaseConnection exited with code 0

          I saw that it was searching for files in the path " /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/" and there were no sqldrivers there so I copied the sqldrivers folder that were generated when I ran the:
          qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
          cmake --build .
          cmake --install .

          After I copied the folder sqldrivers that were generated inside the plugins/ over to the " /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/" and I got the error in the first post above.

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

          @spotted said in I have Mysql plugin installed, but the driver won't load.:

          QSqlDatabase: ForQt driver not loaded

          Please post your code where you want to load the driver. There is no such a driver named "ForQt".

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

          S 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            @spotted said in I have Mysql plugin installed, but the driver won't load.:

            QSqlDatabase: ForQt driver not loaded

            Please post your code where you want to load the driver. There is no such a driver named "ForQt".

            S Offline
            S Offline
            spotted
            wrote on last edited by
            #5

            @Christian-Ehrlicher

            Omg, that fixed it!!

            I originally had this line:
            QSqlDatabase db = QSqlDatabase::addDatabase("ForQt");

            I changed it to:
            QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

            And eveything is fixed!!! Thank you everyone!!!!

            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