Important: Please read the Qt Code of Conduct -

[solved] Qt 5.0 MySQL driver compile and find, but not load

  • I'm trying to use the Qt 5.0 MySQL driver with Visual Studio 10.0 compiler, but some strange behaviour happens when I load it. Adding a MySQL database with the code:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

    I receive the warning below. It's the same generated with QMYSQL3.

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3

    Apparently Qt's plugin system correct find it, but for some reason can't load.

    The plugin was build in accordance with the sql-driver.html doc as follow at Windows 32 and 64 bit using MySQL 5.5.29 (32 bit).

    cd C:\Qt\5.0.0\5.0.0\Src\qtbase\src\plugins\sqldrivers\mysql
    qmake "INCLUDEPATH+=C:/MySQL/include" "LIBS+=C:/MySQL/lib/libmysql.lib"
    nmake install

    Has anybody encontered the same problem?

  • Where do you put qsqlmysql4.dll and libmysql.dll ?

  • Hi,

    MySQL was installed in


    The plugin is created successfully and Qt finds.

    Update: I found a guy with the same "issue": in ODBC driver.

  • Ok maybe you misunderstand my question :-) So you need to have libmysql.dll in application folder path ( or in environment path ) and qsqlmysql4.dll must be in sqldrivers subfolder of application path.

  • Very basic failure. I forgot to copy libmysql.dll in application folder.

    Thanks for replay :)

  • hi all,

    which is this "environment path" or "application folder"

    where should i copy this file?

  • i have the mingw compiler installed

  • i think i found it; it's the "bin" folder from mingw path.
    all the best

  • how is libmysql.dll called in linux?
    I have the same problem now. Native mysql driver not compatible with my mysql so I recompile and cp it to plugins/sqldrivers folder, application folder. application cannot load it but see it in drivers list.

Log in to reply