qt-opensource-linux-x64-5.14.1.run安装的qt可能只支持有限的几种数据库,缺少mysql的支持,按照下文操作添加mysql数据的支持。
操作
sudo apt-get install libmysqlclient-dev -y
export PATH=/opt/Qt5.14.1/5.14.1/gcc_64/bin/:$PATH
tar xf qt-everywhere-src-5.14.1.tar.xz
cd qt-everywhere-src-5.14.1/qtbase/src/plugins/sqldrivers
qmake
Running configuration tests...
Done running configuration tests.
Configure summary:
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. yes
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... no
Qt is now configured forbuilding. Just run "make".
Once everything is built, you must run "make install".
Qt will be installed into "/opt/Qt5.14.1/5.14.1/gcc_64".
Prior to reconfiguration, make sure you remove any leftovers from
the previous build.
make
sudo cp ./plugins/sqldrivers/libqsqlmysql.so /opt/Qt5.14.1/5.14.1/gcc_64/plugins/sqldrivers/
注意替换/opt/Qt5.14.1/5.14.1/的目录,我这里启用了mysql,其他的数据可以安装对应的启动也可以编辑,然后复制到对应的目录下。
重新运行程序。
I0225 20:50:21.861747 885 testSQL.cpp:40] open sucess