MySQL "libs & include" module not found

  • Hi!
    I'm reading the documentation about how to use MySQL in Qt5 applications:

    It says:

    You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. 

    But I cannot find this module in the MySQL installation! I downloaded the last version of the community release.
    Am I missing something obvious?

  • For Windows:
    Download the MySQL Server or the libmysqlclient c connector
    When using the connector you can easily take the zip-only and extract this to some temporary directory.

    You need to link against the libmysql.dll by having INCLUDEPATH set to include the mysql.h directory and LIBS set to include (-L) the lib-path and the library to link against (-l).

    cd %QTDIR%/src/qtbase/src/plugins/sqldrivers/mysql
    qmake "CONFIG+=release" "INCLUDEPATH+=C:/temp/mysqlconnector/include" "LIBS+=-LC:/temp/mysqlconnector/lib" "LIBS+=-llibmysql"
    (n|mingw32-)make install

    For Linux:
    Install the apropriate header files for your linux destribution.

  • Thank you! With your hints I successfully compiled the plugins, which are place into:


    Now I'm facing the common issue of "QMYSQL driver not loaded but available". I read tons of thread about this but I'm asking some clarification about.

    1. I checked the db server is up (from MySQL Workbench I can connect)

    2. in the pro file of my test app I set:

    QT += sql
    1. this is my connection code:
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        qDebug() <<;

    in the documentation I cannot find the page where are described the requisites, like which libs to link with, etc...

    the error is present only in debug mode1 In release it connect successfully! Anyway I have also qsqlmysqld.dll in the plugins folder.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.