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. QMYSQL : Driver not loaded
QtWS25 Last Chance

QMYSQL : Driver not loaded

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 Posters 3.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.
  • TravT Offline
    TravT Offline
    Trav
    wrote on last edited by
    #1

    Im writing this after 2 hours of reading forum after forum with not straight cut answer. Can someone please tell me how to set up QMYSQL properly in order to communicate with a database. I have been using the standard default code provided my QT
    --------( QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); ---------------
    db.setHostName("");
    db.setDatabaseName("Trainer");
    db.setUserName("jefe");
    --------------- db.setPassword("root");------------------------

    and keep getting the dreaded : QMYSQL Driver not loaded error... I'm using mac OS X

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Could be issue with mysql drivers on your box. Try the instructions provided here.
      http://jwintz.me/blog/2016/02/15/fixing-the-qt-mysql-driver-on-macosx-10-dot-11/

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      3
      • TravT Offline
        TravT Offline
        Trav
        wrote on last edited by
        #3

        Followed that link all the way through and unfortunately I'm still getting the same error as above ^

        1 Reply Last reply
        0
        • TravT Offline
          TravT Offline
          Trav
          wrote on last edited by Trav
          #4

          last command I put in was ''''' install_name_tool -change /usr/local/lib/libmysqlclient.18.dylib /usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib libqsqlmysql.dylib '''' I did some research and this seems to be the correct way to be doing it in context of placing the driver i'm not sure whats going on now though from that command it should be working looking in /usr/local/Cellar/mysql/5.7.17 and running ls i have these files present

          cd lib
          192:lib trav$ ls
          libmysqlclient.20.dylib libmysqld.a plugin
          libmysqlclient.a libmysqlservices.a
          libmysqlclient.dylib pkgconfig

          as well as running cd /usr/local/lib then ls I can see that ( see down) are present along with other ones i only included first 5 just for example

          libexiv2.14.0.0.dylib
          libexiv2.14.dylib
          libexiv2.dylib
          libmysqlclient.18.dylib
          libmysqlclient.20.dylib

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

            Hi,

            What does otool -L libqsqlmysql.dylib return ?

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

            TravT 1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              What does otool -L libqsqlmysql.dylib return ?

              TravT Offline
              TravT Offline
              Trav
              wrote on last edited by
              #6

              @SGaist said in QMYSQL : Driver not loaded:

              otool -L libqsqlmysql.dylib

              Thank you for the reply!
              trav$ otool -L libqsqlmysql.dylib
              /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: 'libqsqlmysql.dylib': No such file or directory.
              fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: internal objdump command failed

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

                otool -L /path/to/location/of/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

                TravT 1 Reply Last reply
                0
                • TravT Offline
                  TravT Offline
                  Trav
                  wrote on last edited by
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    otool -L /path/to/location/of/libqsqlmysql.dylib

                    TravT Offline
                    TravT Offline
                    Trav
                    wrote on last edited by
                    #9

                    @SGaist

                    trav$ otool -L /usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib

                    /usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib:
                    /usr/local/opt/mysql/lib/libmysqlclient.20.dylib (compatibility version 20.0.0, current version 20.0.0)
                    /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
                    /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
                    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
                    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

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

                      I'm asking you to run otool on the Qt MySQL plugin. The path I've used in the command samples are meant to be replaced by the actual path to where the plugin is located. I don't know where it is on your system, so don't just copy paste the command, update it as well.

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

                      TravT 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        I'm asking you to run otool on the Qt MySQL plugin. The path I've used in the command samples are meant to be replaced by the actual path to where the plugin is located. I don't know where it is on your system, so don't just copy paste the command, update it as well.

                        TravT Offline
                        TravT Offline
                        Trav
                        wrote on last edited by Trav
                        #11

                        @SGaist Sorry was 3 am. Deleted that comment as soon as I knew what I did I updated it immediately though with the correct path ^

                        trav$ otool -L /usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib

                        /usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib:
                        /usr/local/opt/mysql/lib/libmysqlclient.20.dylib (compatibility version 20.0.0, current version 20.0.0)
                        /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
                        /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
                        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
                        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

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

                          Not the MySQL client library, the Qt MySQL plugiin libqsqlmysql.dylib that can be found in the plugins/sqldrivers folder in your Qt installation.

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

                          TravT 1 Reply Last reply
                          1
                          • SGaistS SGaist

                            Not the MySQL client library, the Qt MySQL plugiin libqsqlmysql.dylib that can be found in the plugins/sqldrivers folder in your Qt installation.

                            TravT Offline
                            TravT Offline
                            Trav
                            wrote on last edited by
                            #13

                            @SGaist
                            pwd
                            /Users/trav/Qt/5.6/clang_64/plugins/sqldrivers

                            trav$ otool -L libqsqlmysql.dylib
                            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.6.0, current version 5.6.0)
                            @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
                            /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
                            /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
                            Traviss-Air:sqldrivers trav$

                            A 1 Reply Last reply
                            0
                            • TravT Trav

                              @SGaist
                              pwd
                              /Users/trav/Qt/5.6/clang_64/plugins/sqldrivers

                              trav$ otool -L libqsqlmysql.dylib
                              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.6.0, current version 5.6.0)
                              @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
                              /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
                              /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
                              Traviss-Air:sqldrivers trav$

                              A Offline
                              A Offline
                              ambershark
                              wrote on last edited by
                              #14

                              @Trav said in QMYSQL : Driver not loaded:

                              @SGaist
                              pwd
                              /Users/trav/Qt/5.6/clang_64/plugins/sqldrivers

                              trav$ otool -L libqsqlmysql.dylib
                              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)

                              Here's your problem... It is looking for mysql in the /opt/local/lib directory (which is a weird directory), when according to your post above it is in /usr/local/opt/mysql.

                              Usually people use /usr/local or /opt. I've never seen /opt/local. But it's not like there's set rules for directories or anything, so to each their own.

                              Anyway use otool to fix those paths and it should work.

                              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

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

                                It's not weird for tools that are external to the distribution if we talk Linux style.

                                In this case, it's macports that is using it like that.

                                In any cas, the parameters passed to install_name_tool must be correct there's no error message telling you that the paths are invalid.

                                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
                                1

                                • Login

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