E
E
Egorithm2017-02-04 22:53:48
Qt
Egorithm, 2017-02-04 22:53:48

Qt. QSqlDatabase: QMYSQL driver not loaded. Why? How to fix?

The code:

#include <QtWidgets>
#include <QtSql>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication App(argc,argv);

    MainWindow *Window = new MainWindow;
    Window->show();

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL","mydb");
    db.setHostName("localhost");
    db.setDatabaseName("institute");
    db.setUserName("root");
    db.setPassword("1234");
    bool ok = db.open();

    int result = App.exec();
    delete Window;

    return result;
}

Compiler:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

Here's what I found in the book:
34d109d36f6f494ea4abdba6647a60ce.png
It's not a fact that because of this, but still it's not clear where to write this code? Here is the code:
configure -plugin-sql-mysql -I C:\Program Files\MySQL\MySQL Server 5.7\include -L C:\Program Files\MySQL\MySQL Server 5.7\lib

Apparently definitely not in the pro file

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel K, 2017-02-05
@EgoRusMarch

pavelk.ru/mysql-5-5-i-qt-qtcreator-4-8-1-windows-7-x64

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question