[solved] QtSql and XAMPP MySql - "QMYSQLdriver not loaded"
-
wrote on 14 Apr 2015, 15:12 last edited by killerman
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 ?
-
wrote on 14 Apr 2015, 15:56 last edited by
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.
-
wrote on 14 Apr 2015, 16:56 last edited by
"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
-
wrote on 14 Apr 2015, 16:58 last edited by
Hi,
you need to set it as System environmental variable
-
wrote on 14 Apr 2015, 17:14 last edited by
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 ?
-
wrote on 15 Apr 2015, 04:54 last edited by
it returns:
"QSqlError<"", "Driver not loaded", "Driver not loaded">"
-
wrote on 15 Apr 2015, 05:40 last edited by
HI,
can you show again your PATH? Is the mysqlclient.dll in the PATH?
-
wrote on 15 Apr 2015, 15:06 last edited by
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
-
wrote on 15 Apr 2015, 15:10 last edited by
you need to add
C:\xampp\lib
in the PATH -
wrote on 15 Apr 2015, 15:53 last edited by
Ok. It works fine now.
Thank You :)
-
wrote on 15 Apr 2015, 15:56 last edited by
You're welcome.
Don't forget to mark the thread as SOLVED
2/12