The mysql driver is not added to QT, so you need to compile it yourself. We assume that you have installed mysql first, you must install mysql-devel, if not installed, it will appear that the problem of-lmysqlclient is not found, the Ubuntu name is libmysqlclient15-dev, so the sudoapt-getinstalllibmysqlclient15-dev next enters the QT to store the mysql driver source code directory, where $ QDIR for your installed QT
The mysql driver is not added to QT, so you need to compile it yourself.
Assume that you have installed mysql
First of all, you must install mysql-devel. If you do not install it, you will find the problem of-lmysqlclient, which is named libmysqlclient15-dev in Ubuntu, so
Sudo apt-get install libmysqlclient15-dev next enter the directory where QT stores mysql driver source code, where $ QDIR is the path to QT installed for you
Cd $ Q
TDIR/
Src/
Plugins/
Sqldrivers/
Mysql executes the qmake operation to generate makefile
Qmake "INCLUDEPATH + =/usr/include/mysql"
"LIBS + =-L/usr/lib/mysql-lmysqlclient_r"
Mysql.
Pro note that INCLUDEPATH is the path of your mysql. h file, and lib is the path of your mysql Library
Then execute make to generate libqsqlmysql. so
Make final execution
Make install to view the generated libqsqlmysql. so in $ QTDIR/plugins/sqldrivers /.
The installation is successful.