QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL
-
Platform: OS X
Qt 5.5.1
Code:QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setPort(3306);
db.setHostName("aName");
db.setDatabaseName("foo");
db.setUserName("aaa");
db.setPassword("bbbb");if (!db.open()) { QMessageBox::warning(0, QObject::tr("Database Error"), db.lastError().text()); return false; }
Output:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7Part of .pro file
QT += core gui
QT += sqlQTPLUGIN += qsqlmysql
...
Any ideas.
Thanks
-
Hi and welcome to devnet,
Please search the forum a bit, that question has been asked many times already.
Do you have the MySQL client library installed ? If so, what version are they ?
You can check the currently link library by running "otool -L libqsqlmysql.dylib"
-
Hi and welcome to devnet,
Please search the forum a bit, that question has been asked many times already.
Do you have the MySQL client library installed ? If so, what version are they ?
You can check the currently link library by running "otool -L libqsqlmysql.dylib"
@SGaist
Hello sir i have the same exact problem, i'm running osx 10.11, QT 5.5 , and MySQL server.
I tried to read most of the post in the forum but couldn't find the solution.here's the otool -L libqsqlmysql.dylib
applications/5.5/clang_64/plugins/sqldrivers/libqsqlmysql.dylib:
libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
@rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.5.0, current version 5.5.0)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.0)
/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)i read that some of the users create a folder in
/opt/local/lib/mysql55/mysql/libmysqlclient20.dylib
that doesn't solve the problem.any idea?
thanks -
Hi and welcome to devnet,
Do you have the MySQL client libraries installed on your system ?
-
Hi and welcome to devnet,
Do you have the MySQL client libraries installed on your system ?
@SGaist
yes i guess
i installed mysql community server and sql workbench.
did u mean the library in :
/usr/local/mysql/lib -
Then use install_name_tool to change the path from
/opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib
to the path where your libmysqlclient can be found in/usr/local/mysql/
-
Then use install_name_tool to change the path from
/opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib
to the path where your libmysqlclient can be found in/usr/local/mysql/
@SGaist
Actually there is no mysql on /opt/ folder so i create it as the path you stated
/opt/local/lib/mysql55/mysql/libmysqlclient.20.dylib
then i coppied the libmysqlclient.20.dylib from /usr/local/mysql/lib/did libmysqlclient20 same as the 18? or i need to change it to 18?
after create it, then i did
install_name_tool -change /opt/local/lib/mysql55/mysql/lib/libqsqlmysql.20.dylib /usr/local/mysql/lib/libmysqlclient.dylibit returned
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] inputmaybe i miss something?
-
Don't copy files around.
Your install_name_tool line is wrong. It should rather be something like
install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.20.dylib path/to/libqsqlmysql.dylib
I don't know whether the changes between 18 and 20 requires a rebuild of the plugin.
-
Don't copy files around.
Your install_name_tool line is wrong. It should rather be something like
install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.20.dylib path/to/libqsqlmysql.dylib
I don't know whether the changes between 18 and 20 requires a rebuild of the plugin.
@SGaist
Wow that solve the problem.
Thankyou very much Sir ! -
You're welcome !
Since you have it working now, please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)
Also, while browsing the forum, consider up-voting answers that helped you, it will make them easier to find for other users :)
-
You're welcome !
Since you have it working now, please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)
Also, while browsing the forum, consider up-voting answers that helped you, it will make them easier to find for other users :)
@SGaist My platform is OS X. I have tried your method.
What terminal outputs islibqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0) /usr/local/Cellar/mysql/5.7.16/lib/libmysqlclient.20.dylib (compatibility version 18.0.0, current version 18.0.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5) @rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.5.0, current version 5.5.1) @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.1) /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
Sttill not working1213.0.0)
-
Hi,
Doesn't work
doesn't help much.What exactly doesn't work ?
What error message do you get ?