MySql open doesn't work.
-
wrote on 11 Apr 2022, 02:56 last edited by
Hi,
I've seen several docs for mysql in action. But I haven't found a solution on the 3rd day.
Test enviorment>
- window 10
- Qt 5.13.2
- mingw73_64
- using mysql-8.0.16 dll
First of all, in code, when database.open is executed, false is returned.
.pro>
QT += sql
Main.cpp>
#include <QtSql> #include <QSqlDatabase> .......................................................................................... qDebug() << "driverlist " << QSqlDatabase::drivers(); QSqlDatabase database; database = QSqlDatabase::addDatabase("QMYSQL"); qDebug() << "db connection " << database.open(); -------------------------------------------
result as blow>
driverlist ("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7") QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 db connection false
I followed the doc below for mysql connection.
https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows-
Some of the tasks listed in the official documentation were executed as follows.
C:\Qt\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -version QMake version 3.1 Using Qt version 5.13.2 in C:/Qt/5.13.2/mingw73_64/lib C:\Qt\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:\mysql-8.0.16-winx64/include" MYSQL_LIBDIR="C:\mysql-8.0.16-winx64/lib" Info: creating stash file **C:\Qt\5.13.2\Src\qtbase\src\plugins\sqldrivers\.qmake.stash Running configuration tests... Checking for DB2 (IBM)... no Checking for InterBase... no Checking for MySQL... yes Checking for OCI (Oracle)... no Checking for ODBC... yes Checking for PostgreSQL... no Checking for SQLite (version 2)... no Checking for TDS (Sybase)... no Done running configuration tests. Configure summary: Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. yes OCI (Oracle) ........................... no ODBC ................................... yes PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt is now configured for building. Just run 'mingw32-make'. Once everything is built, you must run 'mingw32-make install'. Qt will be installed into 'C:\Qt\5.13.2\mingw73_64'. Prior to reconfiguration, make sure you remove any leftovers from the previous build.
-
I copied the libmysql.dll file to the two places below.
C:\Qt\5.13.2\mingw73_64\bin
Where the build exe of the test code is located.
Is there a way to find the cause of the problem or is there any work that is not done yet?
-
wrote on 11 Apr 2022, 04:58 last edited by
Finally solved it.
In conclusion, proceed as follows.
Please refer to those who wish.First, proceed with the basic tasks in the basic document.
Please refer to the site below or what I did in the question I wrote.
https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windowsAnd download the appropriate driver from the site below.
I use qt15.3.2, so I downloaded the 15.3.2 driver.
https://github.com/thecodemonkey86/qt_mysql_driver/releasesI pasted the files into the two folders below each.
C:\Qt\5.13.2\mingw73_64\bin
C:\Qt\5.13.2\mingw73_64\plugins\sqldrivers -
Finally solved it.
In conclusion, proceed as follows.
Please refer to those who wish.First, proceed with the basic tasks in the basic document.
Please refer to the site below or what I did in the question I wrote.
https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windowsAnd download the appropriate driver from the site below.
I use qt15.3.2, so I downloaded the 15.3.2 driver.
https://github.com/thecodemonkey86/qt_mysql_driver/releasesI pasted the files into the two folders below each.
C:\Qt\5.13.2\mingw73_64\bin
C:\Qt\5.13.2\mingw73_64\plugins\sqldriverswrote on 11 Apr 2022, 08:35 last edited by@dennis-kim
Just so I understand (I don't use Windows for Qt): why did you need to build a MySQL driver at all from sources, rather than just downloading an already-built version?
1/3