There are may posts about this, and I've tried everything without any luck.
The error message I get is:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
The code is just a simple connection-test(db, username and password not shown here):
#include "database.h"
#include <QApplication>
#include <QtSql>
#include <QSqlDriver>
database::database()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("xxx:3306");
db.setDatabaseName("xxxx");
db.setUserName("xxx");
db.setPassword("xxx");
bool ok = db.open();
if(ok){
qDebug() << QCoreApplication::libraryPaths();
}else{
}
}
In my .pro I have the following:
QT += qml quick widgets svg core gui multimedia sql
QTPLUGIN += qsqlmysql
CONFIG += c++11
SOURCES += main.cpp \
database.cpp
RESOURCES += \
qml/qml.qrc \
fonts/fonts.qrc\
images/images.qrc
INCLUDEPATH += /usr/include/mysql
main.cpp just calls the database.
In the folder /opt/Qt5.5.0/5.5/gcc_64/plugins/sqldrivers there are these files:
libqsqlite.so libqsqlmysql.so libqsqlpsql.so
In the folder /usr/lib/x86_64-linux-gnu/ I also have
libmysqlclient.so libmysqlclient.so.18
Does anyone know how to solve this problem?