Important: Please read the Qt Code of Conduct -

QMySql not loaded

  • First of all I must say I had spent almost two days searching a solution for this problem. I looked at a lot of forum posts regarding this and I couldn't find a solution.

    When I'am using QMySql driver to access mysql database in my localhost, it says,
    QMySql driver not loaded.
    *But it is in the list of available drivers.

    So far I have figured our there is a dependency problem in the (Located in /Qt/5.6/gcc_64/plugins/sqldriver/)

    Here's the output when I ran the "ldd" command. =>  (0x00007ffeea366000) => not found => /lib/x86_64-linux-gnu/ (0x00007f9d02f94000) => /lib/x86_64-linux-gnu/ (0x00007f9d02d5b000) => /lib/x86_64-linux-gnu/ (0x00007f9d02b41000) => /lib/x86_64-linux-gnu/ (0x00007f9d028e2000) => /lib/x86_64-linux-gnu/ (0x00007f9d02506000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9d022c2000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9d01bb0000) => /lib/x86_64-linux-gnu/ (0x00007f9d01992000) => /usr/lib/x86_64-linux-gnu/ (0x00007f9d0168e000) => /lib/x86_64-linux-gnu/ (0x00007f9d01388000) => /lib/x86_64-linux-gnu/ (0x00007f9d01172000) => /lib/x86_64-linux-gnu/ (0x00007f9d00dad000) => /lib/x86_64-linux-gnu/ (0x00007f9d00ba9000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9d0070f000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9d00357000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9cfe974000) => /usr/lib/x86_64-linux-gnu/ (0x00007f9cfe772000) => /lib/x86_64-linux-gnu/ (0x00007f9cfe56a000) => /lib/x86_64-linux-gnu/ (0x00007f9cfe262000)
    /lib64/ (0x00007f9d033bf000) => /lib/x86_64-linux-gnu/ (0x00007f9cfe024000)

    So it says not found.

    How to fix this error?
    Regards in advance.
    Please help me.

  • Moderators

    Hi @smb564 and Welcome,
    Your system is missing mysql client libraries. Use your distro's tool to install them.
    P. S. This question is quite common on this forum :)

  • @p3c0 Thank you for the reply.
    I installed them.
    I am using ubuntu. I have installed mysql-client & libmysqlclient-dev.
    Are those the files required?

  • Moderators

    @smb564 Well just the mysql client libraries unless you are recompiling the driver.
    Your system probably has a different version of that library.
    For eg. My system has
    Create a symbolic link of the missing library to the library installed on your system.

  • I have created a symbolic link and now the output of ldd command changed as follows.
    ./ /usr/lib/x86_64-linux-gnu/ version `libmysqlclient_16' not found (required by ./ => (0x00007ffd91832000) => /usr/lib/x86_64-linux-gnu/ (0x00007f9479cce000) => /lib/x86_64-linux-gnu/ (0x00007f9479ab5000) => /lib/x86_64-linux-gnu/ (0x00007f947987c000) => /lib/x86_64-linux-gnu/ (0x00007f9479662000) => /lib/x86_64-linux-gnu/ (0x00007f9479403000) => /lib/x86_64-linux-gnu/ (0x00007f9479027000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9478de3000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f94786d1000) => /lib/x86_64-linux-gnu/ (0x00007f94784b3000) => /usr/lib/x86_64-linux-gnu/ (0x00007f94781af000) => /lib/x86_64-linux-gnu/ (0x00007f9477ea9000) => /lib/x86_64-linux-gnu/ (0x00007f9477c93000) => /lib/x86_64-linux-gnu/ (0x00007f94778ce000) => /lib/x86_64-linux-gnu/ (0x00007f94776ca000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9477230000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9476e78000) => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/ (0x00007f9475495000) => /usr/lib/x86_64-linux-gnu/ (0x00007f9475293000) => /lib/x86_64-linux-gnu/ (0x00007f947508b000) => /lib/x86_64-linux-gnu/ (0x00007f9474d83000)
    /lib64/ (0x00007f947a418000) => /lib/x86_64-linux-gnu/ (0x00007f9474b45000)

  • Moderators

    @smb564 Unfortunately linking is not sufficient it seems. Either you will need the exact version or you can compile the driver against the existing libraries. It is described here.

  • @p3c0 I don't know whether I am missing the obvious here. But I can't seem to find a folder like $QTDIR/qtbase/src/plugins/sqldrivers/mysql neither

  • Moderators

    @smb564 You will need to install the source components too. The installer provides an option during installation.

  • @p3c0 Thank you very much for your help! Now it works. :)

    I installed with source and followed the instructions in the Qt docs and manually built it.

  • @smb564 I had the same problem with QMYSQL not loaded. I ran
    $sudo apt-get installlibqt4-sql-mysql
    and it worked