Important: Please read the Qt Code of Conduct -

[SOLVED] Mysql driver not loaded error (Ubuntu Desktop 12.04)

  • this topic is copy of "this topic.":
    I copied it because I wrote previous topic to wrong branch of forum and seems that is cause not get answer.

    OS: Ubuntu Desktop 12.04
    QT: 5.1.1
    Mysql Driver: compiled from source
    ldd command show that everything ok
    @test(at)penguin:~/Qt/5.1.1/gcc/plugins/sqldrivers$ ldd => (0xb77da000) => /usr/lib/i386-linux-gnu/ (0xb7494000) => /home/test/Qt/5.1.1/gcc/lib/ (0xb7454000) => /home/test/Qt/5.1.1/gcc/lib/ (0xb6fd0000) => /usr/lib/i386-linux-gnu/ (0xb6eeb000) => /lib/i386-linux-gnu/ (0xb6d41000) => /lib/i386-linux-gnu/ (0xb6d2b000) => /lib/i386-linux-gnu/ (0xb6d26000) => /lib/i386-linux-gnu/ (0xb6d0a000) => /lib/i386-linux-gnu/ (0xb6cde000) => /lib/i386-linux-gnu/ (0xb6cc0000) => /home/test/Qt/5.1.1/gcc/lib/ (0xb6a9e000) => /home/test/Qt/5.1.1/gcc/lib/ (0xb6925000) => /usr/lib/i386-linux-gnu/ (0xb6921000) => /lib/i386-linux-gnu/ (0xb6918000) => /lib/i386-linux-gnu/ (0xb681f000)
    /lib/ (0xb77db000) => /home/test/Qt/5.1.1/gcc/lib/ (0xb52d6000) => /lib/i386-linux-gnu/ (0xb5299000)@
    connection code
    @db = new QSqlDatabase();
    db->addDatabase("QMYSQL", "DB");

    qDebug() << "drivers: "<< QSqlDatabase::drivers();
    if (db->open())
        qDebug() << "Success!";
        qDebug() << db->lastError().text();@

    @Starting /home/test/QtProjects/build-MySQLGUI-Desktop_Qt_5_1_0_GCC_32bit-Release/MySQLGUI...
    drivers: ("QSQLITE", "QMYSQL", "QMYSQL3", "QPSQL", "QPSQL7")
    "Driver not loaded Driver not loaded"@

    made copy of file
    to project source folder and to build folder. Also created sqldrivers subfolder in project source and build folder and made copy of file
    to this sqldrivers folder.

    What do I do wrong? Why I got error “Driver not loaded Driver not loaded”?

    Pz, any suggestion.

  • Qt gurus, please, help

  • Solution was found by user bpalmer7440.

    @I notice your posts about the problems you were having getting the MYSQL
    driver to load in Qt. I was having the exact same problem (even though I
    had all of the libraries and they could be found). At any rate I finally
    found a thread where it became evident that the addDatabase function was
    static on the QSqlDatabase class and doing this worked:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

    instead of this:
    QSqlDatabase db;

    This fixed my problem. I'm not sure why..


    It is fixed my problem too. Thank you everyone, especially Brian.

Log in to reply