Important: Please read the Qt Code of Conduct -

QSqlDatabase: QMYSQL driver not loaded and not available

  • Hello to all, I have the following error :

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

    The problem is that I can find nowhere on the internet how to solve this because there isn't QMYSQL in the available drivers already. I've downloaded MySql using brew, never had a pb but the dylib file isn't even in the plugin folder of Qt.

    Could someone help me? Spent so much time on this already.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Depending on the version of Qt you have the plugin is not provided pre-built anymore because of a change in the license of MySQL, so you have to build it yourself.

  • Hi, for recent Qt versions, the mysql plugin is no longer provided due to license problem of libmysql.
    You will need to build your own. Please refer to the doc:
    Or you can use older versions of Qt.

  • Hello, thank you for the quick response!!
    So I ran the following code :

    qmake -- MYSQL_PREFIX=/usr/local/Cellar/mysql/8.0.19_1/include

    And I get the "documentation" of how to use qmake so I'm guessing I'm doing something wrong...

  • @mturner First you need to cd to [QtDir]/Src/qtbase/src/plugins/sqldrivers which has .pro file and source code files in it.
    It is not the sqldrivers folder with other dylib files.

  • Thank you a lot !!! I was in the wrong plugin/sqldrivers directory. Thank you to all of you!

Log in to reply