Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL

QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 4.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jollyto
    wrote on 3 Nov 2015, 02:01 last edited by
    #1

    Platform: OS X
    Qt 5.5.1
    Code:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setPort(3306);
    db.setHostName("aName");
    db.setDatabaseName("foo");
    db.setUserName("aaa");
    db.setPassword("bbbb");

    if (!db.open()) {
        QMessageBox::warning(0,
                             QObject::tr("Database Error"),
                             db.lastError().text());
        return false;
    }
    

    Output:

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

    Part of .pro file
    QT += core gui
    QT += sql

    QTPLUGIN += qsqlmysql

    ...

    Any ideas.

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Nov 2015, 23:38 last edited by
      #2

      Hi and welcome to devnet,

      Please search the forum a bit, that question has been asked many times already.

      Do you have the MySQL client library installed ? If so, what version are they ?

      You can check the currently link library by running "otool -L libqsqlmysql.dylib"

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply 2 Jan 2016, 19:09
      0
      • S SGaist
        3 Nov 2015, 23:38

        Hi and welcome to devnet,

        Please search the forum a bit, that question has been asked many times already.

        Do you have the MySQL client library installed ? If so, what version are they ?

        You can check the currently link library by running "otool -L libqsqlmysql.dylib"

        L Offline
        L Offline
        lotusgenerat
        wrote on 2 Jan 2016, 19:09 last edited by
        #3

        @SGaist
        Hello sir i have the same exact problem, i'm running osx 10.11, QT 5.5 , and MySQL server.
        I tried to read most of the post in the forum but couldn't find the solution.

        here's the otool -L libqsqlmysql.dylib
        applications/5.5/clang_64/plugins/sqldrivers/libqsqlmysql.dylib:
        libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
        /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
        @rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.5.0, current version 5.5.0)
        @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.0)
        /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
        /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

        i read that some of the users create a folder in
        /opt/local/lib/mysql55/mysql/libmysqlclient20.dylib
        that doesn't solve the problem.

        any idea?
        thanks

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 2 Jan 2016, 21:37 last edited by
          #4

          Hi and welcome to devnet,

          Do you have the MySQL client libraries installed on your system ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          L 1 Reply Last reply 3 Jan 2016, 06:40
          0
          • S SGaist
            2 Jan 2016, 21:37

            Hi and welcome to devnet,

            Do you have the MySQL client libraries installed on your system ?

            L Offline
            L Offline
            lotusgenerat
            wrote on 3 Jan 2016, 06:40 last edited by
            #5

            @SGaist
            yes i guess
            i installed mysql community server and sql workbench.
            did u mean the library in :
            /usr/local/mysql/lib

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 3 Jan 2016, 11:43 last edited by
              #6

              Then use install_name_tool to change the path from /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib to the path where your libmysqlclient can be found in /usr/local/mysql/

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              L 1 Reply Last reply 3 Jan 2016, 13:18
              2
              • S SGaist
                3 Jan 2016, 11:43

                Then use install_name_tool to change the path from /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib to the path where your libmysqlclient can be found in /usr/local/mysql/

                L Offline
                L Offline
                lotusgenerat
                wrote on 3 Jan 2016, 13:18 last edited by
                #7

                @SGaist
                Actually there is no mysql on /opt/ folder so i create it as the path you stated
                /opt/local/lib/mysql55/mysql/libmysqlclient.20.dylib
                then i coppied the libmysqlclient.20.dylib from /usr/local/mysql/lib/

                did libmysqlclient20 same as the 18? or i need to change it to 18?

                after create it, then i did
                install_name_tool -change /opt/local/lib/mysql55/mysql/lib/libqsqlmysql.20.dylib /usr/local/mysql/lib/libmysqlclient.dylib

                it returned
                Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] input

                maybe i miss something?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 3 Jan 2016, 20:54 last edited by
                  #8

                  Don't copy files around.

                  Your install_name_tool line is wrong. It should rather be something like

                  install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.20.dylib path/to/libqsqlmysql.dylib

                  I don't know whether the changes between 18 and 20 requires a rebuild of the plugin.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  L 1 Reply Last reply 4 Jan 2016, 07:41
                  1
                  • S SGaist
                    3 Jan 2016, 20:54

                    Don't copy files around.

                    Your install_name_tool line is wrong. It should rather be something like

                    install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.20.dylib path/to/libqsqlmysql.dylib

                    I don't know whether the changes between 18 and 20 requires a rebuild of the plugin.

                    L Offline
                    L Offline
                    lotusgenerat
                    wrote on 4 Jan 2016, 07:41 last edited by
                    #9

                    @SGaist
                    Wow that solve the problem.
                    Thankyou very much Sir !

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 4 Jan 2016, 10:50 last edited by
                      #10

                      You're welcome !

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

                      Also, while browsing the forum, consider up-voting answers that helped you, it will make them easier to find for other users :)

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      J 1 Reply Last reply 30 Nov 2016, 03:35
                      0
                      • S SGaist
                        4 Jan 2016, 10:50

                        You're welcome !

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

                        Also, while browsing the forum, consider up-voting answers that helped you, it will make them easier to find for other users :)

                        J Offline
                        J Offline
                        JeremyTam
                        wrote on 30 Nov 2016, 03:35 last edited by
                        #11

                        @SGaist My platform is OS X. I have tried your method.
                        What terminal outputs is

                        libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
                        /usr/local/Cellar/mysql/5.7.16/lib/libmysqlclient.20.dylib (compatibility version 18.0.0, current version 18.0.0)
                        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
                        @rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.5.0, current version 5.5.1)
                        @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.1)
                        /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
                        /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
                        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
                        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 
                        

                        Sttill not working1213.0.0)

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 30 Nov 2016, 08:27 last edited by
                          #12

                          Hi,

                          Doesn't work doesn't help much.

                          What exactly doesn't work ?
                          What error message do you get ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved