Solved QMYSQL driver not loaded
-
Hello i try to connected my qt to my bdd but it's don't work the error message is :
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7i try lot of think but nothing work i use Qt Creator 5.12.10 i needs your help. sorry for my bad english
-
@Sakasushi said in QMYSQL driver not loaded:
i try lot of think but nothing work i use Qt Creator 5.12.10 i needs your help. sorry for my bad english
QtCreator is a good IDE, but this is not a relevant information.
What we need to know is:- what OS you are targetting
- what Qt kit you are using to build your project (https://doc.qt.io/qtcreator/creator-targets.html)
Because of Oracle/MySQL licence changes, in newest Qt-Kit, mysql plugin is no more build, but you can build it yourself from sources ==> https://doc.qt.io/qt-5/sql-driver.html#qmysql-for-mysql-or-mariadb-5-and-higher
-
@KroMignon said in QMYSQL driver not loaded:
what OS you are targetting
what Qt kit you are using to build your project (https://doc.qt.io/qtcreator/creator-targets.html)The os I target it's Windows 10 64 bit.
And the kit named Desktop Qt 5.12.10 MinGW 64-bit. -
I solved the problem I had with a video but now I have another problem the bbd does not open I do not know why it is hosted on wampserver I send you the code
#include <QApplication> #include <fenetreconfirmation.h> #include <fenetreinscription.h> #include <sql.h> #include <QtSql> #include <QSqlDatabase> int main(int argc, char *argv[]) { QApplication app(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("http://192.168.1.183/phpmyadmin/"); // @ip serveur MySQL db.setDatabaseName("chronotrail"); // Nom de la base db.setUserName("root"); // Nom utilisateur db.setPassword("1234"); // Mot de passe db.setPort(3306); db.open(); if (db.open()) { qDebug() << "Connection BDD OK"; } else { qDebug() <<"Erreur de connexion à la BDD"; } FenetreInscription *fenetrePourInscription = new FenetreInscription; fenetrePourInscription->show(); return app.exec(); }``` the ip of the wampserver is 192.168.1.183 and it is in sql on a phpmyadmin
-
@Sakasushi
You are sure that the host for the MySQL server isphpmyadmin
?? Does not sound right to me....Obviously, if you get an error you will want to see what's in
QSqlDatabase::lastError()
. -
@Sakasushi as @JonB already has written, you are mixing up MySQL/MariaDB and phpMyAdmin:
- MySQL/MariaDB are database engines
- phpMyAdmin is a database administration tool
If you want to use QSqlDatabase/QSqlQuery/etc., you have to connect to the db engine.