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. Problem with MySQL driver on mac

Problem with MySQL driver on mac

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 2.4k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    Albert Huert
    wrote on last edited by aha_1980
    #1

    Hi,
    I am working on MySQL database on mac, run program generates the following error.

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

    I have MySQL installed on my computer (macOS high Sierra) that has the following driver libmysqlclient.20.dylib. The MySQL path is the following:

    /usr/local/mysql-8.0.15-macos10.14-x86_64/lib

    I have executed the following code:

    cd /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers
    otool -L libqsqlmysql.dylib

    out:
    libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.11.0, current version 5.11.1)
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.11.0, current version 5.11.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/local/mysql/lib/libmysqlclient.20.dylib (compatibility version 20.0.0, current version 20.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)

    Does anyone know how I can connect to my database?
    I have researched in the net and I have found that it is used, install_name_tool –change ,although I am not sure what it is for. I have tried this but obviously something is wrong.
    install_name_tool – change /usr/local/mysql/lib/libmysqlclient.20.dylib /usr/local/mysql-8.0.15-macos10.14-x86_64/lib/libmysqlclient.21.dylib /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

    Thanks for help.

    0_1550367032393_mysql.png
    0_1550367047371_path2.png

    K 1 Reply Last reply
    0
    • A Albert Huert

      Hi,
      I am working on MySQL database on mac, run program generates the following error.

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

      I have MySQL installed on my computer (macOS high Sierra) that has the following driver libmysqlclient.20.dylib. The MySQL path is the following:

      /usr/local/mysql-8.0.15-macos10.14-x86_64/lib

      I have executed the following code:

      cd /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers
      otool -L libqsqlmysql.dylib

      out:
      libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
      @rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.11.0, current version 5.11.1)
      @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.11.0, current version 5.11.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/local/mysql/lib/libmysqlclient.20.dylib (compatibility version 20.0.0, current version 20.0.0)
      /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)

      Does anyone know how I can connect to my database?
      I have researched in the net and I have found that it is used, install_name_tool –change ,although I am not sure what it is for. I have tried this but obviously something is wrong.
      install_name_tool – change /usr/local/mysql/lib/libmysqlclient.20.dylib /usr/local/mysql-8.0.15-macos10.14-x86_64/lib/libmysqlclient.21.dylib /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

      Thanks for help.

      0_1550367032393_mysql.png
      0_1550367047371_path2.png

      K Offline
      K Offline
      kenchan
      wrote on last edited by
      #2

      @Albert-Huert said in Problem with MySQL drive on mac:

      QSqlDatabase: QMYSQL driver not loaded

      does your .pro file specify the library and the path to it correctly?

      A 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It will show you more information about what is happening with the MySQL plugin.

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

        A 2 Replies Last reply
        1
        • SGaistS SGaist

          Hi,

          Start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It will show you more information about what is happening with the MySQL plugin.

          A Offline
          A Offline
          Albert Huert
          wrote on last edited by
          #4

          @SGaist said in Problem with MySQL drive on mac:

          Start your application with the QT_DEBUG_PLUGINS

          Hi,
          how I start application with the QT_DEBUG_PLUGINS?
          thanks for your answer

          jsulmJ 1 Reply Last reply
          0
          • A Albert Huert

            @SGaist said in Problem with MySQL drive on mac:

            Start your application with the QT_DEBUG_PLUGINS

            Hi,
            how I start application with the QT_DEBUG_PLUGINS?
            thanks for your answer

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Albert-Huert If you're using QtCreator go to the Run settings of your projects and add it in "Run Environment".

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            A 1 Reply Last reply
            3
            • jsulmJ jsulm

              @Albert-Huert If you're using QtCreator go to the Run settings of your projects and add it in "Run Environment".

              A Offline
              A Offline
              Albert Huert
              wrote on last edited by
              #6

              @jsulm thank you very much for your help!!

              1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                Start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It will show you more information about what is happening with the MySQL plugin.

                A Offline
                A Offline
                Albert Huert
                wrote on last edited by
                #7

                @SGaist Hi,
                I get this output,

                Got keys from plugin meta data ("QPSQL7", "QPSQL")
                QFactoryLoader::QFactoryLoader() checking directory path "/Users/eduardo/Desktop/build-prueba-Desktop_Qt_5_11_1_clang_64bit-Debug/prueba.app/Contents/MacOS/sqldrivers" ...
                Cannot load library /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
                Referenced from: /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                Reason: image not found)
                QLibraryPrivate::loadPlugin failed on "/Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n Referenced from: /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n Reason: image not found)"
                QSqlDatabase: QMYSQL driver not loaded
                QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

                I have seen that it is recommended to add DYLD_LIBRARY_PATH, but it appears as variable in "run environment".

                0_1550527959570_Run environment.png

                SGaistS 1 Reply Last reply
                0
                • A Albert Huert

                  @SGaist Hi,
                  I get this output,

                  Got keys from plugin meta data ("QPSQL7", "QPSQL")
                  QFactoryLoader::QFactoryLoader() checking directory path "/Users/eduardo/Desktop/build-prueba-Desktop_Qt_5_11_1_clang_64bit-Debug/prueba.app/Contents/MacOS/sqldrivers" ...
                  Cannot load library /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
                  Referenced from: /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                  Reason: image not found)
                  QLibraryPrivate::loadPlugin failed on "/Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n Referenced from: /Users/eduardo/Qt/5.11.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n Reason: image not found)"
                  QSqlDatabase: QMYSQL driver not loaded
                  QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

                  I have seen that it is recommended to add DYLD_LIBRARY_PATH, but it appears as variable in "run environment".

                  0_1550527959570_Run environment.png

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by SGaist
                  #8

                  @Albert-Huert said in Problem with MySQL driver on mac:

                  I have seen that it is recommended to add DYLD_LIBRARY_PATH, but it appears as variable in "run environment".

                  That's correct.

                  Append :/usr/local/mysql/lib/ to it. The semicolon is the separation between paths just as in the PATH environment variable.

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

                  A 1 Reply Last reply
                  3
                  • SGaistS SGaist

                    @Albert-Huert said in Problem with MySQL driver on mac:

                    I have seen that it is recommended to add DYLD_LIBRARY_PATH, but it appears as variable in "run environment".

                    That's correct.

                    Append :/usr/local/mysql/lib/ to it. The semicolon is the separation between paths just as in the PATH environment variable.

                    A Offline
                    A Offline
                    Albert Huert
                    wrote on last edited by
                    #9

                    @SGaist Solved with the instruction you gave me.
                    Thank you

                    1 Reply Last reply
                    0
                    • K kenchan

                      @Albert-Huert said in Problem with MySQL drive on mac:

                      QSqlDatabase: QMYSQL driver not loaded

                      does your .pro file specify the library and the path to it correctly?

                      A Offline
                      A Offline
                      Albert Huert
                      wrote on last edited by
                      #10

                      @kenchan Thank you very much for the help.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Great !

                        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 :)

                        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