Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlDatabase: QMYSQL driver not loaded

QSqlDatabase: QMYSQL driver not loaded

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    matobodo
    wrote on last edited by
    #1

    I have MYSQL database. When I try to execute a query i get this error:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    How can I solve it?

    Code:
    main.cpp
    @#include <QCoreApplication>
    #include <QDebug>
    #include <QtSql>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    QString driver = "QMYSQL";
    
    QSqlDatabase db;
    db = QSqlDatabase::addDatabase(driver,dbName);
    db.setHostName(hostName);
    db.setPort(port);
    db.setDatabaseName(dbName);
    db.setUserName(userName);
    db.setPassword(password);
    
    if (db.open()) {
        qDebug() << "Opened!";
        QSqlQuery *qry = new QSqlQuery(db);
        if (qry->exec&#40;"SELECT * FROM `cechosped_users`"&#41;) {
            qDebug() << "Executed!";
        } else {
            qDebug() << "Error:";
            qDebug() << qry->lastError().text();
        }
    } else {
        qDebug() << "Error:";
        qDebug() << db.lastError().text();
    }
    
    return a.exec&#40;&#41;;
    

    }
    @

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      There are lots of posts related to this problem in this forum. Have a look at those.

      157

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kiwing
        wrote on last edited by
        #3

        check another forum like this one
        http://qt-project.org/forums/viewthread/36482 and
        http://qt-project.org/forums/viewthread/36656

        the key is never tired to read !
        ok brother ?!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved