Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [windows] qmysql driver not loaded

[windows] qmysql driver not loaded

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 3 Posters 1.2k 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.
  • K Offline
    K Offline
    kadynCBR
    wrote on last edited by
    #1

    Hi! I'm currently trying to connect to a mysql database via QT. After searching around all day and yesterday trying to pinpoint whats been giving me this error I've yet to solve it and decided to try and ask myself as I'm rather new to mySQL and not too sure how this all works yet.

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

    I even went to a plain console application just to get this connection to work with no avail, Here's the code to that
    @#include <QCoreApplication>
    #include <QtSql/QSql>
    #include <QtSql/QSqlDatabase>
    #include <QtSql/QSqlError>
    #include <QString>
    #include <iostream>

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

    std::cout << "Beginning connection..\n";
    // SQL database
    QString servername = "www.db4free.net";
    QString dbname = "ksyslancetest";
    QString dbusr = "ksysusr";
    QString dbpass = "ksyslance";
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setConnectOptions();
    db.setHostName(servername);
    db.setDatabaseName(dbname);
    db.setUserName(dbusr);
    db.setPassword(dbpass);

    if(db.open()) {
    std::cout << "Success!";
    } else {
    std::cout << "failed\n";
    QString error = db.lastError().text();
    std::cout << error.toStdString();
    }

    return a.exec();
    }
    @

    annnnnd .pro
    @#-------------------------------------------------

    Project created by QtCreator 2014-08-04T10:37:07

    #-------------------------------------------------

    QT += core
    QT += sql

    QT -= gui

    TARGET = qsqltest
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp
    @
    I've done a myrid of other things trying to troubleshoot this so if you've any questions that could possibly help me please feel free to ask! Thank you!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clochydd
      wrote on last edited by
      #2

      Hi and welcome to DevNet!

      "This ":http://qt-project.org/forums/viewthread/41828/ may help you

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        You also need to have the MySQL client dll containing folder in your PATH environment variable. You can update it in the Run part of the project panel

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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