Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MYSQL driver not loaded when using mariadb on Debian Linux
QtWS25 Last Chance

MYSQL driver not loaded when using mariadb on Debian Linux

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.1k Views
  • 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.
  • T Offline
    T Offline
    tataDanAz
    wrote on 27 Aug 2020, 03:09 last edited by
    #1

    I am using Debian 10 (which by default comes with mariadb instead of mysql. I have the mariadb 10.3 client and 10.3 server installed and functioning. I installed QT 5.11.3 using the apt install command. My version of QT Creator is 4.8.2.
    The relevant code that I am using is:```
    void MainWindow::on_pushButton_clicked()
    {
    QSqlDatabase db = QSqlDatabase::addDatabase("MYSQL");
    db.setHostName("127.0.0.1");
    db.setUserName("root");
    db.setPassword("");
    db.setDatabaseName("nation");

    if (db.open()) {
        QMessageBox::information(this, "Connection", "Database Connected Successfully");
    } else{
        QMessageBox::information(this, "Not Connected", "Database Is Not Connected");
    }
    

    }

    The error that I get is :```
    QSqlDatabase: MYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3
    

    Any assistance in this matter would be appreciated.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on 27 Aug 2020, 03:47 last edited by Bonnie
      #2

      I guess mariadb doesn't have libmysqlclient.so which is needed by the old pre-compiled mysql plugin?
      You can set QT_DEBUG_PLUGINS environment variable to 1 and check the diagnostic information from output.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tataDanAz
        wrote on 27 Aug 2020, 04:48 last edited by
        #3

        libmysqlclient.so is in /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers, but it did not come the standard debian installation. I think it came from a ubuntu .deb file. Here is an extract of the output when application with QT_DEBUG_PLUGINS=1:

        code_QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers" ...
        QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so"
        "Failed to extract plugin meta data from '/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so'" 
                 not a plugin
        QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so"
        Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QSQLITE"
                ]
            },
            "className": "QSQLiteDriverPlugin",
            "debug": false,
            "version": 330499
        }
        
        
        Got keys from plugin meta data ("QSQLITE")
        QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so"
        Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QMYSQL3",
                    "QMYSQL"
                ]
            },
            "className": "QMYSQLDriverPlugin",
            "debug": false,
            "version": 330499
        }
        
        
        Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
        QFactoryLoader::QFactoryLoader() checking directory path "/home/daniel/qtProjects/build-qt5database-Desktop-Debug/sqldrivers" ...text
        

        The most important piece of the output is:

        "Failed to extract plugin meta data from '/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so'" 
                 not a plugin
        

        Is it possible to find a valid version of libmysqlclient.so?

        J B 2 Replies Last reply 27 Aug 2020, 04:57
        0
        • T tataDanAz
          27 Aug 2020, 04:48

          libmysqlclient.so is in /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers, but it did not come the standard debian installation. I think it came from a ubuntu .deb file. Here is an extract of the output when application with QT_DEBUG_PLUGINS=1:

          code_QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers" ...
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so"
          "Failed to extract plugin meta data from '/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so'" 
                   not a plugin
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so, metadata=
          {
              "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "QSQLITE"
                  ]
              },
              "className": "QSQLiteDriverPlugin",
              "debug": false,
              "version": 330499
          }
          
          
          Got keys from plugin meta data ("QSQLITE")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so, metadata=
          {
              "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "QMYSQL3",
                      "QMYSQL"
                  ]
              },
              "className": "QMYSQLDriverPlugin",
              "debug": false,
              "version": 330499
          }
          
          
          Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
          QFactoryLoader::QFactoryLoader() checking directory path "/home/daniel/qtProjects/build-qt5database-Desktop-Debug/sqldrivers" ...text
          

          The most important piece of the output is:

          "Failed to extract plugin meta data from '/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so'" 
                   not a plugin
          

          Is it possible to find a valid version of libmysqlclient.so?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 27 Aug 2020, 04:57 last edited by jsulm
          #4

          @tataDanAz said in MYSQL driver not loaded when using mariadb on Debian Linux:

          libmysqlclient.so

          This is NOT Qt plug-in for MySql! This is the client library from MySql/MariaDB. Why is this file in /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers?!
          The correct file name of the plug-in should be libqsqlmysq.so

          Please search for MySQL in this forum: this is asked many many times and was answered many times.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • T tataDanAz
            27 Aug 2020, 04:48

            libmysqlclient.so is in /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers, but it did not come the standard debian installation. I think it came from a ubuntu .deb file. Here is an extract of the output when application with QT_DEBUG_PLUGINS=1:

            code_QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers" ...
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so"
            "Failed to extract plugin meta data from '/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so'" 
                     not a plugin
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so, metadata=
            {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "QSQLITE"
                    ]
                },
                "className": "QSQLiteDriverPlugin",
                "debug": false,
                "version": 330499
            }
            
            
            Got keys from plugin meta data ("QSQLITE")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so, metadata=
            {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "QMYSQL3",
                        "QMYSQL"
                    ]
                },
                "className": "QMYSQLDriverPlugin",
                "debug": false,
                "version": 330499
            }
            
            
            Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
            QFactoryLoader::QFactoryLoader() checking directory path "/home/daniel/qtProjects/build-qt5database-Desktop-Debug/sqldrivers" ...text
            

            The most important piece of the output is:

            "Failed to extract plugin meta data from '/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so'" 
                     not a plugin
            

            Is it possible to find a valid version of libmysqlclient.so?

            B Offline
            B Offline
            Bonnie
            wrote on 27 Aug 2020, 04:57 last edited by
            #5

            @tataDanAz
            No, it is not the most important piece, just because libmysqlclient.so is not supposed to be put in the plugin folder.
            I think you should move it to the qt bin folder.
            The most important piece should be about libqsqlmysql.so.
            Is it loaded successfully? If not, what's the information?

            1 Reply Last reply
            1
            • T Offline
              T Offline
              tataDanAz
              wrote on 27 Aug 2020, 20:16 last edited by
              #6

              @Bonnie said in MYSQL driver not loaded when using mariadb on Debian Linux:

              QT_DEBUG_PLUGINS

              Apparently in Debian libmysqlclient.so is a symbolic link to libmariadbclient.so (at least that's what my limited understanding leads me to believe).
              I copied both files from /usr/lib/x86_64-linux-gnu to /usr/lib/x86_64-linux-gnu/qt5/bin, but I still get the error. (I also tried copying them to /usr/lib/qt5/bin and the directory when my application resides, but that did not work either).
              As far as I can tell, libqsqlmysql.so loaded successfully. Here is the latest extract from the output:

              QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so"
              Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so, metadata=
              {
                  "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                  "MetaData": {
                      "Keys": [
                          "QMYSQL3",
                          "QMYSQL"
                      ]
                  },
                  "className": "QMYSQLDriverPlugin",
                  "debug": false,
                  "version": 330499
              }
              
              Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
              
              QFactoryLoader::QFactoryLoader() checking directory path "/home/daniel/qtProjects/build-qt5database-Desktop-Debug/sqldrivers" ...
              QSqlDatabase: MYSQL driver not loaded
              QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3
              
              
              1 Reply Last reply
              0
              • T Offline
                T Offline
                tataDanAz
                wrote on 27 Aug 2020, 21:05 last edited by
                #7

                I finally discovered the problem. It was a problem in my code.
                Instead of writing

                QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
                

                I wrote

                QSqlDatabase db = QSqlDatabase::addDatabase("MYSQL");
                

                I was attempting to enter the code from a youtube video and I left out a "Q".
                Thanks to all who attempted to help me. I hope that I didn't cause anybody too much difficulty in trying to help me.

                1 Reply Last reply
                0

                2/7

                27 Aug 2020, 03:47

                topic:navigator.unread, 5
                • Login

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