QSqlDatabase: QMYSQL driver not loaded. Why?
-
Hi
I compiled Qt 5.0.2 with MySQL support. Driver plugin is there but program can't load it with a funny message:
@QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3@What am I doing wrong ?
-
Hi,
Could you post what QSqlDatabase::lastError().text() returns ?
-
[quote author="SGaist" date="1364405279"]Hi,
Could you post what QSqlDatabase::lastError().text() returns ?[/quote]
It says:
@
"Driver not loaded Driver not loaded"
@ -
Then, can you post the code where you setup the database connection ?
-
[quote author="SGaist" date="1364418685"]Then, can you post the code where you setup the database connection ?[/quote]
Does it really matter? in first line when I'm trying to create a new database I got this error. I always connect this way, and it always works.
@
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); // This is the line I got error
db.setHostName("127.0.01");
db.setDatabaseName("test");
db.setUserName("root");
db.setPassword("pass");
bool ok = db.open();
@Note: I'm using my own build: http://sourceforge.net/p/eboqt/
-
Do you have the MySql client dll accessible in your PATH when running your program ?
-
[quote author="SGaist" date="1364472156"]Do you have the MySql client dll accessible in your PATH when running your program ?[/quote]
:| Yes I have it. I found that Qt distros provided by mingwbuilds do the same thing with MySQL on Win 8...
-
Get the same error with Qt5.3 MINGW install on Windows8
@QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLCIPHER QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7@The QSQLCIPHER and QSQLITE drivers are working perfectly...
-
SOLVED ... have to find and copy the libmysql.dll from the place MYSQL it is installed on the computer to the [QTDIR]/mingw482_32/bin/ folder.
Maybe its also working if you add the MYSQL install path to system variables?Just be sure you copy the good dll ...mean that if your Qt installed is 32 bits then will need the 32 bits dll too.
My first mistake was to copy the 64 bits dll and was not working -
@Sir.Costy For me worked by copying libmysql.dll from MYSQL folder to [QTDIR]/mingw482_32/bin/ folder.
Thanks male!