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. QMYSQL driver not loaded

QMYSQL driver not loaded

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 6 Posters 16.6k 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.
  • A Offline
    A Offline
    AndreaCT
    wrote on 6 May 2020, 21:40 last edited by
    #1

    Hello everyone!
    I am trying to connect my application to a local database, through the MYSQL connector, but the connection not work. I searched the forum and saw that it is a common problem, but I haven't found the solution.

    This is my code:

    83c39a55-5c75-4813-acf3-441a04b27dac-image.png

    Initially the error was:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7

    Next, I put qsqlmysql.dll into :\Qt\5.14.2\mingw73_32\plugins\sqldrivers, and the error become:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    I read that is need put libmysql.dll (32 bit) into :\Qt\5.14.2\mingw73_32\bin

    However this not work for me...

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on 6 May 2020, 23:31 last edited by
      #2

      Hello! Did you build qsqlmysql.dll yourself?
      And if your libmysql.dll is from MySQL Connector/C 6.1, you'll need VS2015 runtime installed on your machine.

      A 1 Reply Last reply 7 May 2020, 15:06
      1
      • J Offline
        J Offline
        JSher
        wrote on 7 May 2020, 00:21 last edited by
        #3

        In QT Creator go to projects on the left side(wrench) and click on it(make sure your in debug). Then under build/build environment add the variable QT_DEBUG_PLUGINS and set it to 1.

        Then run again and read the plugin trace and see where it is looking for libmysql.dll and put it there. And make sure you do what @Bonnie said.

        --James

        K 1 Reply Last reply 7 May 2020, 04:39
        1
        • J JSher
          7 May 2020, 00:21

          In QT Creator go to projects on the left side(wrench) and click on it(make sure your in debug). Then under build/build environment add the variable QT_DEBUG_PLUGINS and set it to 1.

          Then run again and read the plugin trace and see where it is looking for libmysql.dll and put it there. And make sure you do what @Bonnie said.

          --James

          K Offline
          K Offline
          Ketan__Patel__0011
          wrote on 7 May 2020, 04:39 last edited by Ketan__Patel__0011 5 Jul 2020, 04:42
          #4

          @JSher

          What is your qt version or which toolkit you are using ?
          And which mysql version you are using ?

          J 1 Reply Last reply 7 May 2020, 10:19
          0
          • L Offline
            L Offline
            lincoln
            wrote on 7 May 2020, 05:57 last edited by
            #5

            https://www.youtube.com/watch?v=bFkXjfFvmJo&feature=share

            Solitary wolf

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Thombou
              wrote on 7 May 2020, 08:11 last edited by Thombou 5 Jul 2020, 10:36
              #6

              Can you open your qsqlmysql.dll and libmysql.dll with the dependancy walker to make sure all dependancies are found? In my case the libmysql.dll needed 2 additional dlls (I took it from the MySql Server 8.0).

              If you built the driver yourself and installed is according to the documentation (not only compiling), you should not need to copy the qsqlmysql.dll file to the folder \Qt\5.14.2\mingw73_32\plugins\sqldrivers. It should be done during the installation, if I am not wrong.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AndreaCT
                wrote on 7 May 2020, 09:04 last edited by
                #7

                I had brutally copied qsqlmysql.dll into sqldriver.
                I just built the plugin as explained here (https://doc.qt.io/qt-5/sql-driver.html) and it works perfectly.

                Thank you all

                1 Reply Last reply
                0
                • K Ketan__Patel__0011
                  7 May 2020, 04:39

                  @JSher

                  What is your qt version or which toolkit you are using ?
                  And which mysql version you are using ?

                  J Offline
                  J Offline
                  JSher
                  wrote on 7 May 2020, 10:19 last edited by
                  #8

                  @Ketan__Patel__0011 What is your qt version or which toolkit you are using ?
                  And which mysql version you are using ?

                  I am using 5.9.9 and I do not have mysql(connecting to a remote server), I just downloaded the connector 6.1 I think that has the libs already built.

                  --James

                  K 1 Reply Last reply 7 May 2020, 10:25
                  0
                  • J JSher
                    7 May 2020, 10:19

                    @Ketan__Patel__0011 What is your qt version or which toolkit you are using ?
                    And which mysql version you are using ?

                    I am using 5.9.9 and I do not have mysql(connecting to a remote server), I just downloaded the connector 6.1 I think that has the libs already built.

                    --James

                    K Offline
                    K Offline
                    Ketan__Patel__0011
                    wrote on 7 May 2020, 10:25 last edited by Ketan__Patel__0011 5 Jul 2020, 10:29
                    #9

                    @JSher

                    Copy libmysql.dll into your <QTDIR>bin
                    Copy libmysql.dll into this Path : C:\Windows\System32
                    Copy libmysql.dll into this Path : C:\Windows

                    Set The Environment Variable PATH :

                    C:\Program Files\MySQL\MySQL Server 5.6\include

                    C:\Program Files\MySQL\MySQL Server 5.6\lib

                    1 Reply Last reply
                    0
                    • B Bonnie
                      6 May 2020, 23:31

                      Hello! Did you build qsqlmysql.dll yourself?
                      And if your libmysql.dll is from MySQL Connector/C 6.1, you'll need VS2015 runtime installed on your machine.

                      A Offline
                      A Offline
                      AndreaCT
                      wrote on 7 May 2020, 15:06 last edited by
                      #10

                      @Bonnie About the deployment I put libmysql.dll (from MySQL Connector / C 6.1) in the folder containing the exe. Does VS2015 runtime need to be installed on each device? To avoid this, can I take the library from other sources?

                      B 1 Reply Last reply 7 May 2020, 16:58
                      0
                      • A AndreaCT
                        7 May 2020, 15:06

                        @Bonnie About the deployment I put libmysql.dll (from MySQL Connector / C 6.1) in the folder containing the exe. Does VS2015 runtime need to be installed on each device? To avoid this, can I take the library from other sources?

                        B Offline
                        B Offline
                        Bonnie
                        wrote on 7 May 2020, 16:58 last edited by Bonnie 5 Jul 2020, 17:50
                        #11

                        @AndreaCT Yes, you can use older versions that has no dependency on VS runtimes. Just check the dll with dependency walker.
                        EDITED
                        Actually as I checked, VS runtimes are necessary since 6.1.10.
                        I think you can try MySQL Connector/C version 6.1.9 or 6.1.6

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          AndreaCT
                          wrote on 7 May 2020, 20:18 last edited by
                          #12

                          Perfect, thank you very much

                          1 Reply Last reply
                          0

                          2/12

                          6 May 2020, 23:31

                          10 unread
                          • Login

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