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.5k 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 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 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
      1
      • J Offline
        J Offline
        JSher
        wrote on 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

        Ketan__Patel__0011K 1 Reply Last reply
        1
        • J JSher

          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

          Ketan__Patel__0011K Offline
          Ketan__Patel__0011K Offline
          Ketan__Patel__0011
          wrote on last edited by Ketan__Patel__0011
          #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
          0
          • lincolnL Offline
            lincolnL Offline
            lincoln
            wrote on 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 last edited by Thombou
              #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 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
                • Ketan__Patel__0011K Ketan__Patel__0011

                  @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 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

                  Ketan__Patel__0011K 1 Reply Last reply
                  0
                  • J JSher

                    @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

                    Ketan__Patel__0011K Offline
                    Ketan__Patel__0011K Offline
                    Ketan__Patel__0011
                    wrote on last edited by Ketan__Patel__0011
                    #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

                      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 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
                      0
                      • A AndreaCT

                        @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 last edited by Bonnie
                        #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 last edited by
                          #12

                          Perfect, thank you very much

                          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