[solved] QtSql and XAMPP MySql - "QMYSQLdriver not loaded"
-
Hi, I' ve installed XAMPP and i've created a database but i get error while opening it.
Here is my programm:
QCoreApplication a(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("people"); db.setUserName("root"); db.setPassword(""); if(db.open()) qDebug() << "Opened"; else qDebug() << "Not opened"; return a.exec();
i get en error:
QsqlDatabase: QMYSQL driver not loaded QsqlDatabase: available drivers ... QMYSQL...
So, the driver is installed byt it wont work.
What is wrong ?
-
Hi and welcome to devnet,
I think there are a lot of similar threads in the forum; BTW the first thing to check is if the MySQL client library (not the Qt driver) is available in the PATH.
QSqlDatabase::drivers()
return the list on Qt drivers installed on the machine.
When you try to use a driver, it needs to load the native DB client library; if the client library cannot be loaded the driver loading fails.This is why you can see the driver as available but you're not able to load it.
-
"BTW the first thing to check is if the MySQL client library (not the Qt driver) is available in the PATH."
It is not. This is my PATH.
PATH=C:\Documents and Settings\All Users\Dane aplikacji\Oracle\Java\javapath;
D:\aplikacje\Borland\CBUILD~1\Bin ;
D : \Ap1ikacje\Borland\CBUILD~1\Projects\Bp1;
C:\WINDOWS\system32;
C:\WINDOWS ;
C:\WINDOWS\system32\wbem;
C:\PROGRAM FILES\QUICKTIME\QTSYSTEM;
D:\Aplikacje\Internet Explorer;
C:\Program Files\QuickTime \QTSystem;I've tried to use the code below(in cmd) but it still don't work...
set PATH=C:\xampp\mysql
-
Ok. I did it using this tutorial:
http://www.computerhope.com/issues/ch000549.htm#windowsxpbut QT still gives the same error...
-
Hi and welcome to devnet,
What does QSqlDatabase::lastError() return ?
-
PATH=C:\Documents and Settings\All Users\Dane aplikacji\Oracle\Java\javapath;
D:\aplikacje\Borland\CBUILD~1\Bin ;
D : \Ap1ikacje\Borland\CBUILD~1\Projects\Bp1;
C:\WINDOWS\system32;
C:\WINDOWS ;
C:\WINDOWS\system32\wbem;
C:\PROGRAM FILES\QUICKTIME\QTSYSTEM;
D:\Aplikacje\Internet Explorer;
C:\Program Files\QuickTime \QTSystem;
C:\xampp\mysql;I've added the folder with mysql in xampp. Is it wrong?
i've searched for mysqlclient.dll in xampp file but it is not there.
There are only mysqlclient.lib files in .../xampp/lib and .../xampp/lib/debug