MySQL Driver Issue with QT on Ubuntu 16 and 18 LTS

There can be a lot of Stackover and QT Forum threads about this issue. I had to read most of them till got the right solution.
It doesn’t matter if I set my .pro file correctly or not if didn’t install MySQL driver’s version needed by QT
If you faced with “QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7” and wanted to smash your computer’s monitor, no worries I got your back!

  • sudo gedit /etc/apt/sources.list
  • add to the bottom : deb trusty-security main
  • save and exit
  • sudo apt-get update -y
  • sudo apt-get install libmysqlclient18 -y
  • cd /opt/Qt5.11.2/5.11.2/gcc_64/plugins/sqldrivers
  • sudo ldconfig
  • sudo ldd

You have to install libmysqlclient18 and by default sources list you cannot install this library. I used Qt 5.11 with offline installer when I typed this small note on my private repo and your QT location is possibly different then mine.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *