Why is the QMYSQL driver not loaded in QT5.2?

My program writes with QT5.2 and uses mysql. I heard that QT5.2 already contains the MYSQL driver. However, when I compile and run my program, it compiled successfully, but the launch failed with an error:

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

My program is this:

  QSqlDatabase db=QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("tradingsystem"); db.setUserName("root"); db.setPassword(""); if(!db.open()) { //.....; } 

And in .pro I add the following:

  QT += sql 

Mysql is provided by XAMPP.My OS is win7-x64-sp1-ultimate, and XAMPP is version 1.8.2. System path:

  C:\Program Files (x86)\SepanderSoft; C:\Program Files (x86)\Intel\iCLS Client\; C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; C:\Program Files\Intel\Intel(R) Management Engine Components\DAL; C:\Program Files\Intel\Intel(R) Management Engine Components\IPT; C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL; C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT; C:\Program Files\Intel\WiFi\bin\; C:\Program Files\Common Files\Intel\WirelessCommon\; C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86; C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64; C:\Program Files\Microsoft\Web Platform Installer\; C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\; C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\; C:\Program Files\Microsoft SQL Server\110\Tools\Binn\; D:\Software\MySQL\MySQL Enterprise Backup 3.8.2\ 

XAMPP Location:

  D:\XAMPP 

QT Location:

  D:\Software\Qt 

I installed mysql server-5.6-64bit in D: \ Software \ MySQL, and when it encountered mysql in XAMPP, I uninstalled mysql server-5.6-64bit.

+7
mysql qt
source share
4 answers

I met the same error and fixed it successfully by copying the file

C:\Program Files (x86)\MySQL\MySQL Connector.C 6.1\lib\libmysql.dll

in

C:\Qt\Qt5.3.1\5.3\mingw482_32\bin

Youtube link

+7
source share

I ran into the same problem, and even the "Hồ Sĩ Sơn" solution did not work. Then I found out that I installed the 64-bit version of MySQL and tried to use it in the 32-bit version of Qt.

Copying the DLL from the address below did not help:

 C:\Program Files\MySQL\MySQL Connector.C 6.1\lib\libmysql.dll 

Instead, download the 32-bit version of libmysql.dll from:

https://dev.mysql.com/downloads/connector/c/

and copy it to the mingw folder.

In my case, I had to copy the DLL to the msvc2010 folder since I am using the Visual Studio compiler:

 C:\Qt\5.4\msvc2010_opengl\bin 

Hope this helps. :)

+5
source share

Adding a message due to a lack of reputation.

I managed to solve my problem using a combination of messages Hồ Sĩ Sơn, Ram and Sumanth (Thank you both).

Here are my specific steps:

Check out the version of Qt Creator that I run by visiting Help -> About Qt Creator. I found that I am running a 32-bit version.

Now that I know which version I'm running, I switched to the 32-bit version of the MySQL connector. This was found in C: \ Program Files (x86) \ MySQL \ MySQL Connector C 6.1 \ lib.

I copied the libmysql.dll file found in this folder and pasted it into C: \ Qt \ 5.9.2 \ mingw53_32 \ bin \ since I am compiling MinGW. Please note that this is a 32-bit folder.

Rebooted Qt Creator and rebuilt my project.

The steps that challenged me corresponded to the x-bit version of Qt Creator, my compiler and driver, and then restarted Qt Creator.

Hope this helps someone out there!

+2
source share

I ran into the same problem and decided to follow these steps.

By doing 6 hours of research, the problem is finally resolved. I used 64-bit Windows 10, 32-bit Qta and 64-bit MySQL server.

QSQLITE and QODBC worked fine, but ran into a QMYSQL problem.

Later I downloaded " mysql-connector-c-6.1.11-win32.zip " (if it is a 32-bit QT) from https://dev.mysql.com/downloads/connector/c/ copied " libmysql.dll " to QT path C: \ Qt \ 5.9.3 \ mingw53_32 \ bin.

Wow .. it worked great.

+1
source share

All Articles