Important: Please read the Qt Code of Conduct -

[solved]Qt 5.2 with MySQL- driver not loaded

  • Hello there,
    I've downloaded and installed Qt 5.2 32 bit for android, my machine is windows 8 64bit, I also have visual studio 2012 installed, MySQL 5.6.16 32bit is installed.

    I'm trying to connect to a MySQL database, but I always get this error

    QSqlDatabse: QMYSQL driver not loaded
    QSqlDatabse: available drivers: QSQLIT QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    Here is my code
    #include <QCoreApplication>
    #include <QtSql>
    #include <QtDebug>

    int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    return a.exec();

    I've known that in Qt 5.2 there is no need to build the driver, anyway I'v tried and built it but with no difference, I don't know if the built process went well or no.
    Any suggestions please because I spent the last two days searching the net for a solution.

  • Lifetime Qt Champion


    Do you have the path to your MySQL dlls in your PATH environment variable ? Also check that it's the case in the run panel in Qt Creator

  • I added both these paths to my PATH environment
    C:\Program Files\MySQL\MySQL Server 5.6\lib
    C:\Program Files\MySQL\MySQL Server 5.6\include

    But I don't know what you mean by checking the case in the run panel in Qt creator. sorry

  • Lifetime Qt Champion

    Qt Creator -> Projects
    Look at your kit, there's a build - run switch, check run and verify that the PATH in "Run environment" also contains the path to the dlls. You don't need to the the include path in PATH.

  • I've added this path
    C:\Program Files\MySQL\MySQL Server 5.6\lib
    to the path in creator - run, then clean and rebuild and the error is still here

  • Should I have any dlls in this path

    or any other path regarding mysql or plugins ?

  • Lifetime Qt Champion

    Not in the sources no, only in the binary tree

  • what do you mean by binary tree ? Sorry excuse my Ignorant

  • Lifetime Qt Champion

    The folder where the dlls and executable can be found.

    Something like

    I'm not sure for the exact name

  • I have the qsqlmysqld.dll and qsqlmysql.dll in this path
    Is that means that I don't have to build the driver?

  • I found the file qsqlmysql.dll in this path C:\Qt\Qt5.2.0\5.2.0\mingw48_32\plugins\sqldrivers and I run dependacy walker on it and here is a photo of what I got
    ! should be a photo here )!

    any tips?

  • I had similar problems with the postgresql driver when installing on a second Win7 machine. After making sure, that the database drivers were in the path ...mingw..plugins\sqldrivers and ...postgresql\lib and bin I still saw the simillar message (missing driver although in list) and I had to completely build new - now it works!
    Perhaps you may delete the build-directories and build debug or release new.

  • Lifetime Qt Champion

    If I see thing correctly, you have a 64bit MySQL installed and the MinGW Qt package is 32bit

  • @clochydd You mean delete the build-directory of the plugin or what, because I re-installed Qt and didn't build the plugin again, as it isn't required in Qt 5.2

  • Hi Baso, I mean: delete the build directory of your application (ie ...myapp\Debug or ...myapp\Release). The location of your plugins is correct - for testing you may also copy the directory sqldrivers from C:\Qt\Qt5.2.0\5.2.0\mingw48_32\plugins\ to the application build directory ...myapp\Debug\sqldrivers.

  • <SOLVED>
    @SGaist You are right (How embarrassing :) ) the tick was that I downloaded the offline MySQL installer for windows(x86-32bit) the installer is 32bit, but the server combined with it was (5.6 64bit) looks like there is no 5.6 server 32bit so I installed the 5.5 32bit server instead and it worked.

    Thank you all for your help.

  • How do you deal with numbers? Not everyone is good at math. Many of us were vexed by the complexity of those essential abstractions since school days. And still, as adults we need to build certain math skills to be able to make good financial decisions. We need to know the difference between simple and compound interest, and how to calculate each. And for those seeking to invest, the same can be said of dividends. Below are some basic steps to navigate through the labyrinth of figures. We humbly offer this information in a desire to help the mathematically impaired. How many times have you expected more details on how to apply for a payday loan and resorted to an internet search on quick cash advance?" Your search is over, all of the info you'll need is at "":

  • Lifetime Qt Champion

    You're welcome !

    Now that you have it up and running, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

  • @SGalst Done :)

Log in to reply