[Solved]Qt5.2 can find the mysql driver but can not load it
-
os : win7
compiler : mingw4.8(come with Qt5.2)@db = new QSqlDatabase();
db->addDatabase("QMYSQL");
db->setHostName("localhost");
db->setDatabaseName("myclinic");
db->setUserName("root");
db->setPassword(",trth12");qDebug() << loader.errorString(); qDebug() << "drivers: "<< QSqlDatabase::drivers(); if (db->open()) qDebug() << "Success!"; else qDebug() << db->lastError().text();@
messages
*QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL
7
"The shared library was not found."
drivers: ("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7")"Driver not loaded Driver not loaded"*
-
SQL works in plugin concept. Looks like plugin for mysql is missing in your installation. Look at ../plugins/sqldrivers directory and check whether appropriate shared library exist.
-
[quote author="Dheerendra" date="1389242730"]SQL works in plugin concept. Looks like plugin for mysql is missing in your installation. Look at ../plugins/sqldrivers directory and check whether appropriate shared library exist.[/quote]
but the available printed by "errorString" show that QMYSQL is supported
-
It is yourself who have build the MySQL dll?
-
Hi,
You can have the plugin built and it will show up in the list of available Sql plugins. However you still need to have the MySQL dlls available on your system (e.g. have the folder where the MySql dlls are installed in your PATH environment variable)
-
It is possible that this is a debug/release problem.
Make sure you have both:
qsqlmysql.dll
qsqlmysqld.dll (this is needed for debug)The DLLs need to be in your QT plugins/sqldrivers path, or if you plan to release you application make sure you have a sqldrivers path relative to your executable (allways works for me).
-
Thanks, I solved the problem.looks like win7 do not come with the dll
A video show you how to install mysql on windows
"video":http://www.youtube.com/watch?v=AqQc3YqfelE''After install, if you still can't load the driver, go to the lib folder of mysql, copy the libmysql.dll and drop it into the same folder of your exe.
-
AFAIK, no version of Windows comes with MySQL pre-installed (the same for OS X and Linux)
Linux might be an exception since depending on what package you want to install it may come as a dependency