How to make Qt aware of the QMYSQL driver

后端 未结 7 517
春和景丽
春和景丽 2021-01-12 04:26

I\'m trying to access a MySql database from a Qt application but I get the following error:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available dr         


        
7条回答
  •  悲&欢浪女
    2021-01-12 04:58

    This may also happen if your QMYSQL plugin is linked against the "wrong" mysql_client.a or it isn't in the LD_LIBRARY_PATH. I had this problem on OSX because mysql was installed via ports, and I fixed it with:

    install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient_r.18.dylib libqsqlmysql.dylib
    

提交回复
热议问题