Solved QMYSQL driver not loaded - again?...
-
Hello,
as i am quite new to this topic, i read many other posts to the mysql errors but still got problems to understand.My program already works with a database on my computer made by sqlite. Now i want to change it, so that i can read from a database on a webserver. I installed xampp and created a database. The changes in my code are the following:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("tempdata"); db.setPort(3306); db.open();
I included <QSql> in the header and QTPLUGIN += qsqlmysql in .pro-File.
When i run the programm it gets me the error:QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
"Driver not loaded Driver not loaded"
QSqlQuery::exec: database not open
"Driver not loaded Driver not loaded"
QSqlQuery::value: not positioned on a valid recordMy system is Windows 10. Please help me or link a related post, so that i can understand :)
-
Hi
If the database server is on other computer then
db.setHostName("localhost");
should be ip or name of that server as far as I know.
localhost cannot be "other" pc.
Also note the port 3306.
Might be blocked by windows firewall. -
okay, but this is not the problem, i think.
I read of copying files like libmysql.dll and so on,
but i do not understand what i exactly have to do :/ -
@mr__710
well does it still work to load database from own pc?did u read this ?
https://forum.qt.io/topic/25638/qsqldatabase-qmysql-driver-not-loaded-why -
with data.db on my pc it worked.
db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("C:/sqlite/data.db");
this was no problem.
-
@mr__710 said
ok, so now you will use
QMYSQL
and you did install MYSQL on your pc and copied the DLL so qt can use it ?
and you must also use
IP in db.setHostName
if the database is on other pc. -
I installed MYSQL to c://MySql.
What files do i have to copy and in which folder of QTdir? -
it depends on your qt version but this for 5
http://seppemagiels.com/blog/create-mysql-driver-qt5-windows
Step 5 -
Perfect, with mingw it works now.
Unfortunately i have to compile it on android with armeabi-v7.There i get errors again, what do i have to change?
-
@mr__710 ¨
uhh, sorry. I have no idea about android.
Maybe open new topic with errors from android building? -
ok, thank you so far.
If someone wants to help: http://forum.qt.io/topic/61141/mysql-database-connection-mingw-yes-android-no