I have Mysql plugin installed, but the driver won't load.
-
I've done all of the researching and went through every thread but I cannot get it to work.
I followed the instructions according to the docs like this for installation:
mkdir build-sqldrivers
cd build-sqldriversqt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
cmake --build .
cmake --install .I have debugged, it and this is what I am getting:
09:28:04: Starting /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/DatabaseConnection...
qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers" ...
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QSQLITE"
]
},
"archlevel": 2,
"className": "QSQLiteDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QMYSQL",
"QMARIADB"
]
},
"archlevel": 2,
"className": "QMYSQLDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QODBC"
]
},
"archlevel": 2,
"className": "QODBCDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QODBC")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlpsql.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlpsql.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QPSQL"
]
},
"archlevel": 2,
"className": "QPSQLDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers" ...
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlite.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlite.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QSQLITE"
]
},
"archlevel": 2,
"className": "QSQLiteDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlmysql.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlmysql.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QMYSQL",
"QMARIADB"
]
},
"archlevel": 2,
"className": "QMYSQLDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlodbc.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlodbc.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QODBC"
]
},
"archlevel": 2,
"className": "QODBCDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QODBC")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlpsql.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlpsql.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QPSQL"
]
},
"archlevel": 2,
"className": "QPSQLDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
QSqlDatabase: ForQt driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
Failed to connect.
09:28:04: /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/DatabaseConnection exited with code 0bolded text The debugging doesn't really tell me what is wrong. Can someone please help me, I spent a lot of time on this already.
-
Hi, maybe Qt gets confused because it loads twp different Mysql dylibs:
/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib
/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers/libqsqlmysql.dylib(when I run a similar app and turn on QT_DEBUG_PLUGINS=1 I only see the first dylib)
What happens if you remove the second one? -
The files inside of the Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/ were what I placed there myself. I removed the folder and this is the result and also the first original error:
10:27:06: Starting /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/DatabaseConnection...
qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers" ...
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QSQLITE"
]
},
"archlevel": 2,
"className": "QSQLiteDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QMYSQL",
"QMARIADB"
]
},
"archlevel": 2,
"className": "QMYSQLDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QODBC"
]
},
"archlevel": 2,
"className": "QODBCDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QODBC")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlpsql.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlpsql.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QPSQL"
]
},
"archlevel": 2,
"className": "QPSQLDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers" ...
QSqlDatabase: ForQt driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
Failed to connect.
**10:27:06: /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/**DatabaseConnection exited with code 0I saw that it was searching for files in the path " /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/" and there were no sqldrivers there so I copied the sqldrivers folder that were generated when I ran the:
qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
cmake --build .
cmake --install .After I copied the folder sqldrivers that were generated inside the plugins/ over to the " /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/" and I got the error in the first post above.
-
The files inside of the Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/ were what I placed there myself. I removed the folder and this is the result and also the first original error:
10:27:06: Starting /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/DatabaseConnection...
qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers" ...
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlite.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QSQLITE"
]
},
"archlevel": 2,
"className": "QSQLiteDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlmysql.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QMYSQL",
"QMARIADB"
]
},
"archlevel": 2,
"className": "QMYSQLDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QODBC"
]
},
"archlevel": 2,
"className": "QODBCDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QODBC")
qt.core.plugin.factoryloader: looking at "/Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlpsql.dylib"
qt.core.plugin.loader: Found metadata in lib /Users/nhivo/Qt/6.4.0/macos/plugins/sqldrivers/libqsqlpsql.dylib, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QPSQL"
]
},
"archlevel": 2,
"className": "QPSQLDriverPlugin",
"debug": false,
"version": 394240
}qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL")
qt.core.plugin.factoryloader: checking directory path "/Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/sqldrivers" ...
QSqlDatabase: ForQt driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
Failed to connect.
**10:27:06: /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/**DatabaseConnection exited with code 0I saw that it was searching for files in the path " /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/" and there were no sqldrivers there so I copied the sqldrivers folder that were generated when I ran the:
qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
cmake --build .
cmake --install .After I copied the folder sqldrivers that were generated inside the plugins/ over to the " /Users/nhivo/Desktop/Qt/build-DatabaseConnection-Qt_6_4_0_for_macOS-Debug/" and I got the error in the first post above.
@spotted said in I have Mysql plugin installed, but the driver won't load.:
QSqlDatabase: ForQt driver not loaded
Please post your code where you want to load the driver. There is no such a driver named "ForQt".
-
@spotted said in I have Mysql plugin installed, but the driver won't load.:
QSqlDatabase: ForQt driver not loaded
Please post your code where you want to load the driver. There is no such a driver named "ForQt".
Omg, that fixed it!!
I originally had this line:
QSqlDatabase db = QSqlDatabase::addDatabase("ForQt");I changed it to:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");And eveything is fixed!!! Thank you everyone!!!!