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 on Windows
QtWS25 Last Chance

QSqlDatabase: QMYSQL driver not loaded on Windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
mysqlmysql 64bitmysql driverc++
4 Posts 2 Posters 2.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.
  • J Offline
    J Offline
    jalway
    wrote on last edited by
    #1

    Hello,

    I realize this is a problem that has been addressed on here, I've been reading posts and trying things, but I just can't get this to work.

    I'm getting the "QMYSQL driver not loaded" error. I'm on Windows 10. I have Qt 6.3.1 (that's what the folder off of the Qt root has) and am using mingw_64.

    I used MySql Workbench to create the database and a table and populate it and that all is in place.

    Then, I basically followed what this guy is doing in this tutorial:
    https://www.youtube.com/watch?v=_u7TcjIDNzw&t=451s&ab_channel=ParwizForogh

    I added the libmysql.dll and libmysqld.dll into the "bin" folder. That is in: Qt/6.3.1/mingw_64/bin. I also put the dlls where the executable is. The debug executable.

    I have these headers:

    #include <QtSql>
    #include <QSqlDatabase>
    

    and I have this code to connect to the database:

    void MainWindow::on_btnTransferData_clicked()
    {
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("127.0.0.1");
        db.setUserName("root");
        db.setPassword("root");
        db.setDatabaseName("accordtest");
    
        if(db.open()){
            QMessageBox::information(this,"Connection","Database Connected Successfully!");
        }else{
            QMessageBox::information(this,"Not Connected","Database is Not Connected.");
        }
    }
    

    At the end of all of this, it's still refusing to connect.

    Here is the application output in the Qt Creator Application Output window:

    20:17:47: Starting E:\Projects\Fiverr\deovindice\build-SimpleApp-Desktop_Qt_6_3_1_MinGW_64_bit-Debug\debug\SimpleApp.exe...
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QPSQL
    QML debugging is enabled. Only use this in a safe environment.
    20:17:55: E:\Projects\Fiverr\deovindice\build-SimpleApp-Desktop_Qt_6_3_1_MinGW_64_bit-Debug\debug\SimpleApp.exe exited with code 0
    

    I'd appreciate any help with this. I am new to Qt. I just started using it a few days ago.

    Thanks!
    ...John

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

      @jalway said in QSqlDatabase: QMYSQL driver not loaded on Windows:

      I added the libmysql.dll and libmysqld.dll into the "bin" folder. That is in: Qt/6.3.1/mingw_64/bin. I also put the dlls where the executable is.

      And do you also compile the Qt mysql plugin as decribed in the documentation and asked here at least twice a week?

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

      J 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @jalway said in QSqlDatabase: QMYSQL driver not loaded on Windows:

        I added the libmysql.dll and libmysqld.dll into the "bin" folder. That is in: Qt/6.3.1/mingw_64/bin. I also put the dlls where the executable is.

        And do you also compile the Qt mysql plugin as decribed in the documentation and asked here at least twice a week?

        J Offline
        J Offline
        jalway
        wrote on last edited by
        #3

        @Christian-Ehrlicher -- Ah, documentation. I had not seen it. That led me in the right direction. So it works now. I didn't realize there was a "plugin" directory and that the plugin had to be up to date. Thanks!

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

          Then please mark this topic as solved, thx.

          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
          0

          • Login

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