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. QsqlDatabase: QMYSQL driver not loaded but available
Forum Updated to NodeBB v4.3 + New Features

QsqlDatabase: QMYSQL driver not loaded but available

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 5 Posters 1.6k 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.
  • D Offline
    D Offline
    davidesalvetti
    wrote on last edited by
    #1

    Hi all,

    I know this is a common problem, I tried to follow other posts but I can't solve the problem.
    This is my simply code taken by QT:

    #include <QSqlDatabase>
    #include <QDebug>
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
       db.setHostName("bigblue");
       db.setDatabaseName("flightdb");
       db.setUserName("acarlson");
       bool ok = db.open();
       qDebug() << "OK? " << ok;
    }
    

    In the .pro

    QT       += core gui sql
    

    The error is:

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

    I'm using QT 5.9.1 MinGW 32bit.

    I tired to download the zip file for 32 bit from here and the to import the .dll from "mysql-connector-c++-8.0.16-win32/lib" to "C:\Qt\5.9.1\mingw53_32\bin" and also "C:\Qt\5.9.1\mingw53_32\lib" but nothing changed, still the same error. Can somebody give me an hint?

    jsulmJ KroMignonK 2 Replies Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Check e.g. with Dependency Walker if the mysql plugin (in plugins\sql) has all needed dependencies available.

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

      1 Reply Last reply
      2
      • A Offline
        A Offline
        arsinte_andrei
        wrote on last edited by
        #3

        could be that you will need the ms lib dll and you are with minGW??

        1 Reply Last reply
        2
        • D davidesalvetti

          Hi all,

          I know this is a common problem, I tried to follow other posts but I can't solve the problem.
          This is my simply code taken by QT:

          #include <QSqlDatabase>
          #include <QDebug>
          MainWindow::MainWindow(QWidget *parent) :
              QMainWindow(parent),
              ui(new Ui::MainWindow)
          {
              ui->setupUi(this);
          
              QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
             db.setHostName("bigblue");
             db.setDatabaseName("flightdb");
             db.setUserName("acarlson");
             bool ok = db.open();
             qDebug() << "OK? " << ok;
          }
          

          In the .pro

          QT       += core gui sql
          

          The error is:

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

          I'm using QT 5.9.1 MinGW 32bit.

          I tired to download the zip file for 32 bit from here and the to import the .dll from "mysql-connector-c++-8.0.16-win32/lib" to "C:\Qt\5.9.1\mingw53_32\bin" and also "C:\Qt\5.9.1\mingw53_32\lib" but nothing changed, still the same error. Can somebody give me an hint?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @davidesalvetti Also, you can set QT_DEBUG_PLUGINS (https://doc.qt.io/qt-5/deployment-plugins.html) before starting your app and then expect its output.

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

          1 Reply Last reply
          2
          • D davidesalvetti

            Hi all,

            I know this is a common problem, I tried to follow other posts but I can't solve the problem.
            This is my simply code taken by QT:

            #include <QSqlDatabase>
            #include <QDebug>
            MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow)
            {
                ui->setupUi(this);
            
                QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
               db.setHostName("bigblue");
               db.setDatabaseName("flightdb");
               db.setUserName("acarlson");
               bool ok = db.open();
               qDebug() << "OK? " << ok;
            }
            

            In the .pro

            QT       += core gui sql
            

            The error is:

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

            I'm using QT 5.9.1 MinGW 32bit.

            I tired to download the zip file for 32 bit from here and the to import the .dll from "mysql-connector-c++-8.0.16-win32/lib" to "C:\Qt\5.9.1\mingw53_32\bin" and also "C:\Qt\5.9.1\mingw53_32\lib" but nothing changed, still the same error. Can somebody give me an hint?

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by KroMignon
            #5

            @davidesalvetti I had a similar issue with MySQL plugin, as far as I known, Qt MySQL Plugin requires connector/c not connector/c++.
            ==> https://downloads.mysql.com/archives/c-c/
            I had experience that it works with version 6.1.1 and older (version 6.1.2 and newer did not work on my PC)!

            Download it from mysql, and put a copy in C:\Qt\5.9.1\mingw53_32\bin, this should work.... in fact it works for me ;)

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            D 1 Reply Last reply
            2
            • KroMignonK KroMignon

              @davidesalvetti I had a similar issue with MySQL plugin, as far as I known, Qt MySQL Plugin requires connector/c not connector/c++.
              ==> https://downloads.mysql.com/archives/c-c/
              I had experience that it works with version 6.1.1 and older (version 6.1.2 and newer did not work on my PC)!

              Download it from mysql, and put a copy in C:\Qt\5.9.1\mingw53_32\bin, this should work.... in fact it works for me ;)

              D Offline
              D Offline
              davidesalvetti
              wrote on last edited by
              #6

              @KroMignon wow, it works now! I was taking the wrong connector, thank you for the right link!

              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