1

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

I'm struggling for 2 days to figure it out. I did my research trust me. None of those solutions worked for me. When I execute

/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so 

I get not a dynamic executable. So I guess it's not a good file because when I execute ldd on libqsqlite.so I get

linux-vdso.so.1 (0x00007f80db0f5000)
    libQt5Sql.so.5 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f80da96d000)
    libQt5Core.so.5 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f80da1bd000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f80d9f9e000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f80d9c15000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f80d9877000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f80d965f000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f80d926e000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f80d9051000)
    libicui18n.so.56 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f80d8bb8000)
    libicuuc.so.56 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f80d8800000)
    libicudata.so.56 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f80d6e1d000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f80d6c19000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f80d6a17000)
    libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f80d6700000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f80daed0000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f80d648e000)

Can someone help me to fix this problem with exact steps.Thanks in advance!

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/205044/discussion-on-question-by-mihai-bogdan-qmysql-available-but-not-load). – Samuel Liew Dec 30 '19 at 00:58

1 Answers1

3

I have reopened the question why the steps in the @peppe answer need to be updated for recent versions of Qt.

Steps:

  1. Install the development versions of the packages found above: libmysqlclient-dev

  2. Run the MaintenanceTool from your Qt installation, and be sure to select to install Qt's source code too, or clone the project using:

    git clone -b YOUR_QT_VERSION https://github.com/qt/qtbase.git
    

    or

    git clone -b YOUR_QT_VERSION git://code.qt.io/qt/qtbase.git
    

    in this case YOUR_QT_VERSION=5.13.2)

  3. Go in QTDIR/QT_VERSION/Src/qtbase/src/plugins/sqldrivers/

  4. Run the right qmake, i.e. the one coming from that installation of Qt (not the system wide one or similar). Best way to be sure is providing the full path to it: QTDIR/QT_VERSION/gcc_64/bin/qmake sqldrivers.pro

  5. Run make && make install

eyllanesc
  • 235,170
  • 19
  • 170
  • 241