Problem Loading QMYSQL driver in my Qt Quick project.



  • Hi everybody,
    I'm trying to connect to a MySQL database so in my main.cpp file I added this code:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("example");
        db.setDatabaseName("example");
        db.setUserName("example");
        db.setPassword("mypassord");
        if(!db.open())
           qWarning( "Connection FAILED." );;
    

    When I execute all the project (Qt Quick):

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    Connection FAILED.
    

    It seems like Qt knows QMYSQL driver is available but it doesn't load it.

    I find some information in the forum but it doesn't help me,

    Does anyone know how to fix it? I'm using Qt 5.6 in Ubuntu 16.04-

    Thank you very much.


  • Lifetime Qt Champion

    Hi,

    That has nothing to do with QtQuick.

    Did you install MySQL's client libraries ? If so then run ldd on the Qt's MySQL plugin. You'll likely find that the client library used to build Qt is older than the one you have installed on your machine.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.