Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMYSQL driver not loaded



  • Hello, I would like to connect in a local database, i use MySql/phpMyAdmin with XXAMP in ubuntu, i configure the file my.cnf and add the line bind-adress = 192.168.56.1

    My source :

        m_db.setPort(3306);
        m_db.setHostName("192.168.1.15");
        m_db.setUserName("Test");
        m_db.setPassword("12345");
        m_db.setDatabaseName("Gestion");
       if(!m_db.open())
        {
         qDebug()<<m_db.lastError().text();
         m_db.close();
        }
    

    Output :
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    Thank


  • Lifetime Qt Champion

    Hi,

    Please take the time to search the forum, this question has been asked many times over the years and recently.

    You likely have more a recent version of the MySQL client libraries that the one used to build the plugin. You can check that by running ldd on the Qt MySQL plugin. If so then install the MySQL client libraries dev package and rebuild the plugin (only the plugin there's no need to build of all Qt).



  • For compiling a Plugin Library for your MySql Version, go to "QT_Path/Your_Version/Src/qtbase/src/plugins/sqldrivers/mysql/". In this directory execute qmake and then make.



  • Sorry for late reply, I had a problem with Qt.
    I compiled, but I have the same error when I connect

    alt text


  • Lifetime Qt Champion

    Do you have the MySQL .dlls folder in your PATH ?

    If not then they won't be found when you start your application thus the plugin can't be loaded.

    You can modify the PATH environment variable in the Run part of the Project panel in Qt Creator.





  • It works. I added libmysql.dll "C:\mysql\lib" in the project.
    thanks for the help !! :)


  • Lifetime Qt Champion

    You're welcome !

    Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)


Log in to reply