Qt: Windows 10: QMYSQL driver not loaded

10,058

Solution 1

Download the 32-bit version of libmysql.dll; check here for details: qt 5.8 sql connection error:QMYSQL driver not loaded on windows 10

Solution 2

My version is QT 5.11.1. I met same problem. I copied libmysql.dll

from

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

to

C:\Qt\Qt5.11.1\5.11.1\mingw53_32\bin.

Finally,I succeeded.

Share:
10,058
McLan
Author by

McLan

Updated on June 14, 2022

Comments

  • McLan
    McLan almost 2 years

    In Short: I am trying to link my Qt5.5 to MySQL but it is not working.

    The long story begins when I tried to use MySQL as in:

    QSqlDatabase theDatabase = QSqlDatabase::addDatabase("QMYSQL");
    

    But when I run my application, I get the following messages:

    QSqlDatabase: QMYSQL driver not loaded

    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    At this point, I looked online to see how to fix this.

    Then I found on Qt Documentation that I need to build the MySQL plugin. So, I followed the guidance:

    1. I donwloaded mysql-installer-community-5.7.19.0
    2. I tried to instal MySQL. However, during the installation, there was no Libs & Include Files Module to install !!
    3. But I continued the installation and run MySQL57 succesfully as a service locally.
    4. I could not of course build the plugin because there is not sqldrivers folder in my installed files.

    I started looking all over the internet for solution. Then:

    1. According to this youtube answer, I needed to copy libmysql.dll from C:\Program Files\MySQL\MySQL Server 5.7\bin to C:\Qt\Qt5.5.1\5.5\mingw492_32\bin

    I run my application, but again I have the same error !! So:

    1. I copied the file libmysql.dll from C:\Program Files\MySQL\MySQL Connector.C 6.1\lib to the same location C:\Qt\Qt5.5.1\5.5\mingw492_32\bin,

    However, again I have the same error.

    I am now stuck, don't know what to do.

    P.S.: I have sql in my .pro file in Qt-application

    • rakib_
      rakib_ over 6 years
      Maybe the most likely solution if all the scenario you have mentioned is to build Qt with you toolchain and produce libmysql.dll and trying using that one. Actually I faced this problem on GNU/Linux and rebuilding Qt solved my case.
  • McLan
    McLan over 6 years
    Thanks, it works now. it doesn't work though with 64-bit. Many thanks again
  • Don Joe
    Don Joe over 4 years
    Thank you so much! I've been looking for a solution for two days, and now it finally works.
  • Jeruntu
    Jeruntu over 3 years
    This also worked for me! libmysql.dll has to go to the bin folder of qt installation.