Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thecodemonkey86/qt_mysql_driver
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
https://github.com/thecodemonkey86/qt_mysql_driver
cpp dll mysql mysql-library qsqldatabase qt5 qt6 sql-driver
Last synced: 3 days ago
JSON representation
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
- Host: GitHub
- URL: https://github.com/thecodemonkey86/qt_mysql_driver
- Owner: thecodemonkey86
- License: other
- Created: 2019-09-12T21:38:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-02T14:13:32.000Z (about 2 months ago)
- Last Synced: 2025-01-12T00:04:53.507Z (10 days ago)
- Topics: cpp, dll, mysql, mysql-library, qsqldatabase, qt5, qt6, sql-driver
- Homepage:
- Size: 210 KB
- Stars: 435
- Watchers: 21
- Forks: 59
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.LGPLv21
Awesome Lists containing this project
README
Typical symptom when trying to connect to MySQL / MariaDB using Qt but without the necessary plugin is the runtime error
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QMYSQLSince the Qt Company cannot provide qsqlmysql.dll / libqsqlmysql.so in binary form, you have to build it on your own, which can be a pain. Here is a build for various Qt versions. Get precompiled qsqlmysql.dll for Windows / libqsqlmysql.so for Linux from releases. Be sure to match your Qt version and compiler (Microsoft Visual C++/MSVC, MinGW) EXACTLY. For example if you use Qt 6.4.2, you cannot use driver version 6.4.1 or 6.4.3
This is helpful to you? If you wish, you have the possibility to support me by donating here. Thank you so much everyone who has donated so far
Latest Qt6 version: Download for Qt 6.8.1 here
For Android see 3rd party repository https://github.com/sayyyed/qt_android_mysql_driver/releases/tag/qt_mysql_driver_for_android
Deployment
1) copy qsqlmysql.dll (release build) / MSVC: qsqlmysqld.dll, MinGW: qsqlmysql.dll+qsqlmysql.debug (debug build) to subdirectory "sqldrivers" of application directory (or build directory while developing)
2) copy libmysql.dll (MySQL library) and the libcrypto/libssl OpenSSL libraries from zip file (or from https://dev.mysql.com and https://kb.firedaemon.com/support/solutions/articles/4000121705 respectively) to application directory (or more generally, any directory that is registered in PATH environment variable)
Building from source (Qt6/CMake)
Windows
for MSVC:Prerequisites:
1. Install MSVC Compiler (C++ Desktop Toolkit from [Visual Studio 2022 Setup](https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022&source=VSLandingPage&includeRecommended=true&cid=2030))
2. Install Qt incl. Sources, CMake and Ninja from Maintenance Tool
3. Install MySQL library, e.g. by using [Oracle's Installer](https://dev.mysql.com/downloads/installer/) or use the zip file from [here](https://github.com/thecodemonkey86/qt_mysql_driver/releases/tag/libmysql)```console
set PATH=%PATH%;C:\Qt\Tools\CMake_64\bin;C:\Qt\Tools\Ninja
C:
cd C:\Qt\6.8.1\Src\qtbase\src\plugins\sqldrivers
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
call C:\Qt\6.8.1\msvc2022_64\bin\qt-cmake.bat -G "Ninja Multi-Config" . -DMySQL_INCLUDE_DIR="E:\qt_creator\libs\libmysql\include" -DMySQL_LIBRARY="E:\qt_creator\libs\libmysql\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.8.1\msvc2022_64" -DCMAKE_CONFIGURATION_TYPES=Release;Debug -DQT_GENERATE_SBOM=OFF
ninja
ninja install
pause
```for MinGW:
Prerequisites:
1. Install Qt incl. Sources, CMake and MinGW from Maintenance Tool
2. Install MySQL library, e.g. by using [Oracle's Installer](https://dev.mysql.com/downloads/installer/) or use the zip file from [here](https://github.com/thecodemonkey86/qt_mysql_driver/releases/tag/libmysql)```console
set PATH=%PATH%;C:\Qt\Tools\mingw1310_64\bin
C:
cd C:\Qt\6.8.1\Src\qtbase\src\plugins\sqldrivers
call C:\Qt\6.8.1\mingw_64\bin\qt-cmake.bat -G "Ninja Multi-Config" . -DMySQL_INCLUDE_DIR="E:\qt_creator\libs\qmysql_driver\mysql-connector-c-6.1.11-winx64\include" -DMySQL_LIBRARY="E:\qt_creator\libs\qmysql_driver\mysql-connector-c-6.1.11-winx64\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.8.1\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
```