Important: Please read the Qt Code of Conduct -

QSqlDatabase: QMYSQL driver not loaded

  • I had installed mysql before days. about mysql like below information:

    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 31
    Server version: 5.7.19-0ubuntu0.16.04.1 (Ubuntu)
    mysql> show databases;
    | Database           |
    | information_schema |
    | sakila             |
    2 rows in set (0.06 sec)

    I begin to use the Qt to connect mysql, like below snippet:

        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        bool bOpenOk =;
            qDebug() << db.lastError().text();


    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    "Driver not loaded Driver not loaded"

    I searched the error in internet. and find some way.

    1. use ldd
    :~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ l***
    :~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ ldd | grep "not found" => not found
    :/usr/lib/x86_64-linux-gnu$ ls libmysqlclient*
    libmysqlclient.a -> ->
    :/usr/lib/x86_64-linux-gnu$ sudo cp
    1. and use ldd again, had other error
    :~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ ldd | grep "not found"
    ./ /usr/lib/x86_64-linux-gnu/ version `libmysqlclient_18' not found (required by ./

    I also tried use ln -s, but, not work, had the same error.
    I also tried use apt install libmysqlcliend18-dev, but not found the package.
    I had tried many ways from internet, not work. like below links:
    stack overflow

    I also had the libssl and libcryto error, and from below way, i worked it out.

    How to work it out about QMYSQL driver not loaded ?

  • Moderators

    You have a version mismatch from what I can tell. Your Qt's plugin is linked against one version of the mysqlclient library and you have another version in your system path.

  • @kshegunov Thank you very much.

    and which version of Qt support ? or how to update let it to support

    or which version of MySql has

    if there is one way that just to update let it to support, it is better way for me.

  • @kshegunov

    Hi, friend. I work it out.

    Just to install libmysqlclient18 is ok.

    my way:

    1. download libmysqlclient18
    2. install it

Log in to reply