Library / SDK
thecodemonkey86/qt_mysql_driver avatar
thecodemonkey86/qt_mysql_driver

qt_mysql_driver ships prebuilt QMYSQL plug-ins for the Qt versions you cannot compile

Typical symptom: QMYSQL driver not loaded. Solution: get pre-built Qt SQL driver plug-in required to establish a connection to MySQL / MariaDB using Qt. Download qsqlmysql.dll binaries built from official Qt source code

537 stars68 forksUnknownNOASSERTION

At a glance

What is it?
Because the Qt Company does not publish the MySQL SQL driver as a binary, every Qt application that talks to MySQL or MariaDB has to compile qsqlmysql itself, and a version mismatch produces the runtime error QMYSQL driver not loaded. This repository publishes prebuilt qsqlmysql.dll and libqsqlmysql.so for a range of Qt versions, plus the CMake recipe to build your own, with the strict rule that the driver version must match your Qt version and compiler exactly.
Who is it for?
Adopt this repository if you hit the QMYSQL driver not loaded error on Windows or Linux and you would rather download a matching plug-in than build Qt from source. Do not adopt it without checking the exact version pairing, because a driver built for a neighbouring Qt version will not load.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 21 days ago.
What is it written in?
GitHub does not report a main language for this repository.

Answers come from the project's GitHub data, last synced on October 22, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The error, and why it happens at all

The whole repository is organised around one runtime error. When you try to connect to MySQL or MariaDB using Qt without the necessary plug-in, Qt prints:

text
 QSqlDatabase: QMYSQL driver not loaded
 QSqlDatabase: available drivers: QMYSQL

The second line is the confusing part. The driver appears to be listed as available and yet is not loaded, which is a contradiction that sends people looking in the wrong place. What it actually means is that Qt found the QMYSQL plug-in entry but could not load the shared library behind it, usually because the file is missing, is in the wrong directory, or was built against a different Qt.

The root cause is a licensing and distribution decision. Since the Qt Company cannot provide qsqlmysql.dll or libqsqlmysql.so in binary form, you have to build it on your own, which the documentation says can be a pain. That is the gap this repository fills.

So the repository is a distribution point for binaries that Qt itself will not ship, plus a written procedure for producing them. The primary language is not even recorded as one, since the artefact is a compiled C++ plug-in rather than a source project, and the topics are cpp, dll, mysql, mysql-library, qsqldatabase, qt5, qt6 and sql-driver.

The version pairing rule, which is the thing to get right

The documentation is emphatic about this, and the emphasis is the whole point of the project.

You have to match your Qt version and compiler, Microsoft Visual C++ or MSVC, or MinGW, exactly. The example given is that if you use Qt 6.4.2, you cannot use driver version 6.4.1 or 6.4.3.

That example is worth reading carefully, because it rules out the obvious shortcut. A developer who sees a driver for 6.4.x and their Qt is 6.4.2 might reasonably assume the 6.4 line is close enough. It is not. The plug-in is a shared library that links against the Qt libraries it was compiled with, and the loader expects an exact match of the Qt version it was built for.

The release naming follows the Qt version rather than the driver's own version, and the tags are qmysql_6.12.0 from 2026-10-02, qmysql_6.11.2 from 2026-08-19 and qmysql_6.11.1 from 2026-05-14. The current Qt 6 download is the 6.12.0 one, and the documentation notes that for Android there is a third party repository instead, since the Android case is handled by a separate project.

The last push was on 2026-10-02, the same day as the newest tag, so the release line is current.

Deployment is two copy operations

The deployment instructions are short and they are the part most people get wrong, because the driver file alone does not make a working connection.

The first step is to copy the driver plug-in into a sqldrivers subdirectory of the application directory, or the build directory while you are developing. The documentation is specific about which file for which build: qsqlmysql.dll for a release build, and for MSVC the debug build is qsqlmysqld.dll, while for MinGW the debug build adds qsqlmysql.debug alongside qsqlmysql.dll.

The second step is to copy the MySQL library and the OpenSSL libraries. That means libmysql.dll for MySQL, plus the libcrypto and libssl OpenSSL libraries, taken from the zip file or from the MySQL and FireDaemon download pages. These go into the application directory, or more generally into any directory that is registered in the PATH environment variable.

So the dependency chain is three files or sets of files: the Qt SQL driver plug-in in sqldrivers, the MySQL client library, and the OpenSSL libraries. The second and third are not Qt's responsibility at all, they are what the driver links against, and forgetting them produces a driver that is present but will not load, which is the same error as before.

The screenshots in the documentation show the two directory layouts, which is the fastest way to check your own installation against a working one.

Building it yourself with Qt 6 and CMake

The build recipe is given for Windows with both compilers, and it is the same shape in both cases: point the PATH at the CMake, compiler and Ninja tools, change into the Qt source tree for the SQL driver plug-ins, run the Qt-provided CMake wrapper with the MySQL paths and an install prefix, then build and install.

For MSVC the prerequisites are the MSVC compiler from the Visual Studio 2022 setup, then Qt including sources with CMake and Ninja from the Maintenance Tool, then the MySQL library. The sequence is:

console
set PATH=%PATH%;C:\Qt\Tools\CMake_64\bin;C:\Qt\Tools\Ninja
C:
cd C:\Qt\6.9.2\Src\qtbase\src\plugins\sqldrivers
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
call C:\Qt\6.9.2\msvc2022_64\bin\qt-cmake.bat -G "Ninja Multi-Config" . -DMySQL_INCLUDE_DIR="C:\Users\Administrator\Documents\qt_creator\lib\libmysql\include" -DMySQL_LIBRARY="C:\Users\Administrator\Documents\qt_creator\lib\libmysql\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.9.2\msvc2022_64" -DCMAKE_CONFIGURATION_TYPES=Release;Debug  -DQT_GENERATE_SBOM=OFF
ninja
ninja install
pause

For MinGW the prerequisites are Qt including sources with CMake and MinGW from the Maintenance Tool, and the MySQL library. The same steps run with a different Qt toolchain path, a MinGW compiler path and the MinGW install prefix, and the toolchain path includes the MinGW 13.1.0 64 bit directory:

console
set PATH=%PATH%;C:\Qt\Tools\CMake_64\bin;C:\Qt\Tools\mingw1310_64\bin;C:\Qt\Tools\Ninja
C:
cd C:\Qt\6.9.2\Src\qtbase\src\plugins\sqldrivers
call C:\Qt\6.9.2\mingw_64\bin\qt-cmake.bat -G "Ninja Multi-Config" . -DMySQL_INCLUDE_DIR="C:\Users\Administrator\Documents\qt_creator\lib\libmysql\include" -DMySQL_LIBRARY="C:\Users\Administrator\Documents\qt_creator\lib\libmysql\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.9.2\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe" -DCMAKE_CONFIGURATION_TYPES=Release;Debug   -DQT_GENERATE_SBOM=OFF
ninja
ninja install
pause

Two details in those commands are worth noticing. The source directory is the Qt source tree itself, at qtbase src plugins sqldrivers, so you need the Qt sources installed rather than only the binaries. And the configuration types include both Release and Debug, which is what produces the two plug-in files the deployment step expects.

What the repository actually contains

The repository is minimal, which is consistent with a project whose output is release artefacts rather than a buildable source tree.

At the top level there is a README.md, a .gitignore, a .github directory, and two licence files, LICENSE.LGPLv21 and LICENSE.LGPLv3. That pair of licences is the point: the Qt SQL driver plug-ins are built from Qt's own source, which is licensed under the LGPL, and both the LGPL 2.1 and the LGPL 3 texts are included. The platform is recorded as a custom licence that the hosting service cannot classify, but the presence of the two LGPL files in the tree says plainly where the underlying code comes from.

So the prebuilt binaries are third-party LGPL code repackaged, and the licences travel with them. Anyone distributing a Qt application with a bundled driver is the one who has to think about the LGPL obligations, and the fact that the licences are in the repository is a helpful starting point.

The project is maintained by a single person, thecodemonkey86, and the README carries a PayPal donation link with a note that donations are welcome. The releases page is where the binaries live, and the newest Qt 6 download is linked directly from the readme.

Editorial conclusion

Adopt this repository if you hit the QMYSQL driver not loaded error on Windows or Linux and you would rather download a matching plug-in than build Qt from source. Do not adopt it without checking the exact version pairing, because a driver built for a neighbouring Qt version will not load. Before you download anything, check three things: your exact Qt version, down to the patch level, the compiler you built Qt with, since MSVC and MinGW need different binaries, and whether you also need the MySQL client library and the OpenSSL libraries copied next to your executable, because the driver alone is not enough to connect.

Frequently asked questions

What causes the QMYSQL driver not loaded error in Qt?

You are missing the qsqlmysql plug-in or it cannot be loaded, usually because it was not copied into a sqldrivers subdirectory of the application directory, because the MySQL or OpenSSL libraries it needs are not on the PATH, or because the plug-in was built for a different Qt version or compiler.

Which qsqlmysql version should I download for my Qt install?

The one that matches your Qt version exactly, down to the patch level, and your compiler. The documentation gives the example that if you use Qt 6.4.2 you cannot use driver version 6.4.1 or 6.4.3, so a neighbouring release is not a substitute.

Where do I put the Qt MySQL driver and its dependencies?

Copy the driver plug-in into a sqldrivers subdirectory of the application directory, using qsqlmysqld.dll for an MSVC debug build and qsqlmysql.dll plus qsqlmysql.debug for a MinGW debug build. Then copy libmysql.dll and the libcrypto and libssl OpenSSL libraries into the application directory or any directory on the PATH.

How do I build the QMYSQL driver from source?

Install the compiler, Qt including sources with CMake and Ninja, and the MySQL library, then use the Qt-provided qt-cmake.bat in the qtbase sqldrivers source directory with the MySQL include and library paths, an install prefix and the Release and Debug configuration types, and finish with ninja and ninja install. Separate command sequences are given for MSVC and for MinGW.

What licence applies to the prebuilt MySQL Qt driver binaries?

The plug-ins are built from the Qt source, so the repository includes the LGPL 2.1 and LGPL 3 licence files. The latest release is qmysql_6.12.0 from 2026-10-02, and for Android the documentation points to a separate third party repository.

Official sources

  1. Issues
  2. README
  3. Releases
  4. thecodemonkey86/qt_mysql_driver on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/thecodemonkey86-qt-mysql-driver.svg)](https://hysenlabs.com/projects/thecodemonkey86-qt-mysql-driver)

Was this useful?