QSqlDatabase: QMYSQL driver not loaded
-
I had installed mysql before days. about mysql like below information:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 31 Server version: 5.7.19-0ubuntu0.16.04.1 (Ubuntu) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | sakila | +--------------------+ 2 rows in set (0.06 sec)I begin to use the Qt to connect mysql, like below snippet:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("sakila"); db.setUserName("xxx"); db.setPassword("xxxxxx"); bool bOpenOk = db.open(); if(!bOpenOk){ qDebug() << db.lastError().text(); } if(db.isOpen()){ db.close(); }Error
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 "Driver not loaded Driver not loaded"I searched the error in internet. and find some way.
- use
ldd
:~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ l libqsqlite.so* libqsqlmysql.so* libqsqlpsql.so* :~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so | grep "not found" ibmysqlclient.so.18 => not found:/usr/lib/x86_64-linux-gnu$ ls libmysqlclient* libmysqlclient.a libmysqlclient.so -> libmysqlclient.so.20 libmysqlclient.so.20 -> libmysqlclient.so.20.3.6 libmysqlclient.so.20.3.6 :/usr/lib/x86_64-linux-gnu$ sudo cp libmysqlclient.so.20.3.6 libmysqlclient.so.18- and use ldd again, had other error
:~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so | grep "not found" ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18: version `libmysqlclient_18' not found (required by ./libqsqlmysql.so)I also tried use
ln -s, but, not work, had the same error.
I also tried useapt install libmysqlcliend18-dev, but not found the package.
I had tried many ways from internet, not work. like below links:I also had the
libssl and libcrytoerror, and from below way, i worked it out.How to work it out about
QMYSQL driver not loaded? - use
-
I had installed mysql before days. about mysql like below information:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 31 Server version: 5.7.19-0ubuntu0.16.04.1 (Ubuntu) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | sakila | +--------------------+ 2 rows in set (0.06 sec)I begin to use the Qt to connect mysql, like below snippet:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("sakila"); db.setUserName("xxx"); db.setPassword("xxxxxx"); bool bOpenOk = db.open(); if(!bOpenOk){ qDebug() << db.lastError().text(); } if(db.isOpen()){ db.close(); }Error
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 "Driver not loaded Driver not loaded"I searched the error in internet. and find some way.
- use
ldd
:~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ l libqsqlite.so* libqsqlmysql.so* libqsqlpsql.so* :~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so | grep "not found" ibmysqlclient.so.18 => not found:/usr/lib/x86_64-linux-gnu$ ls libmysqlclient* libmysqlclient.a libmysqlclient.so -> libmysqlclient.so.20 libmysqlclient.so.20 -> libmysqlclient.so.20.3.6 libmysqlclient.so.20.3.6 :/usr/lib/x86_64-linux-gnu$ sudo cp libmysqlclient.so.20.3.6 libmysqlclient.so.18- and use ldd again, had other error
:~/Qt5.8.0/5.8/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so | grep "not found" ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18: version `libmysqlclient_18' not found (required by ./libqsqlmysql.so)I also tried use
ln -s, but, not work, had the same error.
I also tried useapt install libmysqlcliend18-dev, but not found the package.
I had tried many ways from internet, not work. like below links:I also had the
libssl and libcrytoerror, and from below way, i worked it out.How to work it out about
QMYSQL driver not loaded?You have a version mismatch from what I can tell. Your Qt's plugin is linked against one version of the mysqlclient library and you have another version in your system path.
- use
-
You have a version mismatch from what I can tell. Your Qt's plugin is linked against one version of the mysqlclient library and you have another version in your system path.
@kshegunov Thank you very much.
and which version of Qt support
libmysqlclient.so.20? or how to updatelibqsqlmysql.solet it to supportlibmysqlclient.so.20?or which version of MySql has
libmysqlclient.so.18?if there is one way that just to update
libqsqlmysql.solet it to supportlibmysqlclient.so.20, it is better way for me. -
You have a version mismatch from what I can tell. Your Qt's plugin is linked against one version of the mysqlclient library and you have another version in your system path.
Hi, friend. I work it out.
Just to install
libmysqlclient18is ok.my way:
- download libmysqlclient18
- install it