Problem connecting mysql to my qt application under linux
-
qt.sql.qsqldatabase: QSqlDatabase: QMYSQL driver not loaded
I'm having trouble connecting my application with my mysql database... I was on windows but I've decided to switch to Linux for good.
Can you help me? You can find above the error message on the sql driver I have. -
This is asked very often, you should use search function.
Set QT_DEBUG_PLUGINS env variable before starting your app and examine the output of your application and/or post it here.
See https://doc.qt.io/qt-6/debug.html -
@Alfredy said in Problem connecting mysql to my qt application under linux:
Here is the message I received
There must be a lot more if you properly set QT_DEBUG_PLUGINS as I advised you.
Please do so and post the output, else we can only guess what the problem is... -
Check this please :
qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
qt.core.plugin.factoryloader: looking at "qsqlmysql.debug"
qt.core.plugin.factoryloader: "The shared library was not found."
not a plugin
qt.core.plugin.factoryloader: looking at "libqsqlmimer.so"
qt.core.plugin.loader: Found metadata in lib /home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmimer.so, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QMIMER"
]
},
"archlevel": 1,
"className": "QMimerSQLDriverPlugin",
"debug": false,
"version": 395264
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMIMER")
qt.core.plugin.factoryloader: checking directory path "/home/.../P/MP/NN/App logiciel/gest_/gestion_d/build/Desktop-Release/sqldrivers" ...
qt.core.library: "/home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" cannot load: Cannot load library /home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so: libmysqlclient.so.21: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" : "Cannot load library /home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so: libmysqlclient.so.21: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type"
qt.sql.qsqldatabase: QSqlDatabase: QMYSQL driver not loaded
qt.sql.qsqldatabase: QSqlDatabase: available drivers: QMARIADB QMYSQL QSQLITE QODBC QPSQL QMIMER
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqgif.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqicns.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqico.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqjpeg.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqpdf.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqsvg.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqtga.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqtiff.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqwbmp.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/imageformats/libqwebp.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so" unloaded library
"/home/.../Qt/6.8.0/gcc_64/plugins/platforms/libqxcb.so" unloaded library -
@Alfredy said in Problem connecting mysql to my qt application under linux:
qt.core.library: "/home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" cannot load: Cannot load library /home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so: libmysqlclient.so.21: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" : "Cannot load library /home/.../Qt/6.8.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so: libmysqlclient.so.21: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type"This is your problem. The MySQL client library is missing (libmysqlclient.so.21), download and install it.
-
@Alfredy said in Problem connecting mysql to my qt application under linux:
How do I download this?
If you search for "mysql client library" you will find https://dev.mysql.com/downloads/c-api/
But it looks like you're on Linux, in that case install the package containing MySQL client library (on Ubuntu it's libmysqlclient21).