Ubuntu18.04下QSqlDatabase: QMYSQL driver not loaded

error message
19:50:42.751: QSqlDatabase: QMYSQL driver not loaded
19:50:42.751: QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
19:50:42.751: open fail
 "Driver not loaded" 

19:50:42.752: HTTP server listen: true
19:50:42.752: HTTP server2 listen: true
19:50:42.752: HTTP server3 listen: true
19:50:42.752: QSqlDatabase: QMYSQL driver not loaded
19:50:42.752: QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
19:50:42.752: open fail
 "Driver not loaded" 

19:50:42.752: All Down

Error screenshot

insert image description here

Solution

insert image description here
It is found that Qt lacks a dynamic link library, download a libmysqlclient.so.18 from the official website:

https://launchpad.net/ubuntu/xenial/amd64/libmysqlclient18/5.6.25-0ubuntu1

insert image description here
After the download is complete, cd to the file directory and install it

sudo dpkg -i libmysqlclient18_5.6.25-0ubuntu1_amd64.deb

insert image description here
Compile and run the project again, the mysql engine is successfully loaded, and no related errors appear.

insert image description here

Guess you like

Origin blog.csdn.net/qq_42257666/article/details/123299883