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. Issues with QMYSQL driver
Forum Update on Monday, May 27th 2025

Issues with QMYSQL driver

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
4 Posts 3 Posters 555 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.
  • M Offline
    M Offline
    Mocha Shakea Khan
    wrote on 21 Apr 2019, 00:12 last edited by Mocha Shakea Khan
    #1

    I want to connect qt with mysql databse; i watched this video https://www.youtube.com/watch?v=0quVy31AOw4 and followed the steps. Here's my code.

    I included qtsql/qsqldatabase and qdebug in the header file.

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("127.0.0.1");
    db.setDatabaseName("slmp");
    db.setUserName("root");
    db.setPassword("");

       if (db.open())
           ui->db_label->setText("Connected...");
       else {
           ui->db_label->setText("Failed to connect");
       }
    

    When i execute this code i of course get the failed to connect text and this statement appears in the output:

    19:02:01: Starting D:\workspace\Qt\build-LMS-Desktop_Qt_5_12_3_MSVC2017_32bit-Debug\debug\LMS.exe ...

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

    The video states to copy libmysql.dll from the mysql connector c file into the mingw but i still got the same output. Then i noticed the output is building from the mscv2017_32 file so i copied the libmysql.dll there and after running the program and failing to connect i got this output:

    19:07:16: Starting D:\workspace\Qt\build-LMS-Desktop_Qt_5_12_3_MSVC2017_32bit-Debug\debug\LMS.exe ...

    19:07:21: D:/workspace/Qt/build-LMS-Desktop_Qt_5_12_3_MSVC2017_32bit-Debug/debug/LMS.exe exited with code 0

    I'm not sure if the driver is loaded correctly but there's something wrong with my code or if it's something else. I spent the last 2 days searching for a solution with no avail.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KillerSmath
      wrote on 21 Apr 2019, 00:37 last edited by
      #2

      @Mocha-Shakea-Khan

      A good way to check if your Mysql Driver is working, is trying to run the Sql Browser Example on Qt Project.
      It will notify you if something is wrong or will add the connection on List of connections
      0_1555807015385_sql-browser.gif

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mocha Shakea Khan
        wrote on 21 Apr 2019, 00:52 last edited by
        #3

        I tried running the browser and got a message stating:

        An error occurred while opening the connection: Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found. QMYSQL: Unable to connect

        J 1 Reply Last reply 22 Apr 2019, 08:21
        0
        • M Mocha Shakea Khan
          21 Apr 2019, 00:52

          I tried running the browser and got a message stating:

          An error occurred while opening the connection: Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found. QMYSQL: Unable to connect

          J Online
          J Online
          JonB
          wrote on 22 Apr 2019, 08:21 last edited by JonB
          #4

          @Mocha-Shakea-Khan
          Just a thought: I note your own code is being built for 32-bit. Wherever you got the libmysql.dll etc. libraries from, did you ensure they too are 32-bit? If they are 64-bit it won't load....

          P.S.
          You don't say whether you are downloading a pre-built QMYSQL or compiling it yourself. If it's the latter, have a read of the stickied thread on this forum, https://forum.qt.io/topic/40672/how-to-create-the-plugin-of-mysql-for-qt. In either case Goggle for QMYSQL driver not loaded: there are a lot of hits for this (both on this forum & elsewhere) which may sort you out.

          1 Reply Last reply
          2

          1/4

          21 Apr 2019, 00:12

          • Login

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