2

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

Community
  • 1
  • 1
McLan
  • 2,552
  • 9
  • 51
  • 85
  • 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. – rakib_ Oct 11 '17 at 14:31

2 Answers2

6

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.

Nic3500
  • 8,144
  • 10
  • 29
  • 40
Wade
  • 61
  • 1
  • 3
2

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

Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47