Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [SOLVED] QSqlDatabase: QMYSQL driver not loaded with QMYSQL driver available in OSX Mavericks
Forum Update on Monday, May 27th 2025

[SOLVED] QSqlDatabase: QMYSQL driver not loaded with QMYSQL driver available in OSX Mavericks

Scheduled Pinned Locked Moved Installation and Deployment
28 Posts 7 Posters 40.8k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 30 Dec 2013, 16:30 last edited by
    #8

    Just to be sure do you have this file:

    /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib ?

    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
    • U Offline
      U Offline
      ucmar
      wrote on 30 Dec 2013, 16:52 last edited by
      #9

      Thanks for your hint. I didn't have it, and I also missed the folder "../mysql". I have just tried to copy it from another folder on my mac (a subfolder of a drupal local website), but my application still shoots the same error... :(

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 30 Dec 2013, 21:10 last edited by
        #10

        Since it's in /opt/ I would suspect it's a MacPort install of MySql.

        If you have the same lib you can use install_name_tool to change the path in your 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

        1 Reply Last reply
        0
        • U Offline
          U Offline
          ucmar
          wrote on 31 Dec 2013, 01:17 last edited by
          #11

          Thank you very much SGaist!!! I realized I had mistakenly created only the "../mysql" folder under "/opt/local/lib"! I have then fixed my problem by creating the complete folder path "../mysql55/mysql" as you suggested and copying the file libmysqlclient.18.dylib there. My Database connection is correctly working now! :D

          Wish you a great 2014! Eheh

          Mario

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 31 Dec 2013, 21:26 last edited by
            #12

            You're welcome !

            All the same to you !

            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
            • F Offline
              F Offline
              foxgod
              wrote on 27 Feb 2014, 02:15 last edited by
              #13

              my os is windows 7 ,andI am having an issue with QMYSQL when open a project in Qt5.2. In particular when connecting to the database, i get the following error:

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

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 27 Feb 2014, 10:24 last edited by
                #14

                Hi foxgod,

                Please have a look at the already numerous threads related to this problem with windows. This one is dedicated to OS X.

                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
                • C Offline
                  C Offline
                  cdallago
                  wrote on 2 Apr 2014, 15:38 last edited by
                  #15

                  Hi guys,
                  I'm sorry to open this post again but I found this to be the thread that best approximates my situation.

                  Basically I followed everything until here:
                  [quote author="SGaist" date="1388421018"]Just to be sure do you have this file:

                  /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib ?[/quote]

                  I haven't used macports to install mysql, I used the "MMV MySQL Script":http://code.macminivault.com/
                  Do I need to create that folder in my directory structure and just copy the libmysqlclient.18.dylib there? Also, when did it become libmysqlclient.18.dylib :D Last time I checked you were still talking about libmysqlclient.dylib :S

                  Sorry guys, I've been looking for solutions for weeks now!

                  PS.: My "otool -L libqsqlmysql.dylib " looks like this:

                  libqsqlmysql.dylib:
                  libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
                  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)
                  /Users/sacdallago/Qt5.2.1/5.2.1/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.2.0, current version 5.2.1)
                  /Users/sacdallago/Qt5.2.1/5.2.1/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.2.0, current version 5.2.1)
                  /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
                  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

                  1 Reply Last reply
                  1
                  • C Offline
                    C Offline
                    cdallago
                    wrote on 2 Apr 2014, 15:51 last edited by
                    #16

                    P.P.S.: Looking around I found the 'libmysqlclient.18.dylib' file (in the folder '/usr/local/mysql-5.6.16-osx10.7-x86_64/lib/'), and I copied it to '/opt/local/lib/mysql55/mysql/'.
                    This didn't solve the problem, though :(

                    Any other suggestions?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 2 Apr 2014, 20:09 last edited by
                      #17

                      Hi and welcome to devnet,

                      The location of the library itself is not the key here. Use install_name_tool to update the path to point to your libmysqlclient.18.dylib

                      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
                      • C Offline
                        C Offline
                        cdallago
                        wrote on 5 Apr 2014, 14:22 last edited by
                        #18

                        [quote author="SGaist" date="1396469393"]Hi and welcome to devnet,

                        The location of the library itself is not the key here. Use install_name_tool to update the path to point to your libmysqlclient.18.dylib[/quote]

                        Thanks for the suggestion SGaist! I still could't make it work after using install_name_tool, so I just switched to postgres, which worked out-of-the-box.

                        I will try to figure out how to make MySQL work when I won't have deadlines keeping me awake at night :S

                        Best regards!

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 5 Apr 2014, 20:38 last edited by
                          #19

                          Check both Qt's MySQL plugin and libmysqlclient with otool -L to ensure that everything can be found correctly

                          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
                          • OrbotronO Offline
                            OrbotronO Offline
                            Orbotron
                            wrote on 11 Feb 2016, 13:29 last edited by Orbotron 2 Nov 2016, 13:31
                            #20

                            Re: [SOLVED] QSqlDatabase: QMYSQL driver not loaded with QMYSQL driver available in OSX Mavericks

                            Just wanted to reply 2 years later to let people know that this solution still works on OSX if you download the offline installer qt-opensource for Mac OSX.

                            Thanks!

                            I ran otool on my libsqlmysql.dylib and it was pointing at

                            [dank:...clang_64/plugins/sqldrivers]$ 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.5.0, current version 5.5.1)
                            	...
                            

                            I install MySQL with Homebrew

                            [dank:...clang_64/plugins/sqldrivers]$ l /usr/local/lib/ | grep 18
                            drwxrwxr-x   32 root  admin   1.1K Feb 10 18:49 ..
                            drwxr-xr-x    3 dank  admin   102B Nov 18 12:35 python2.7
                            lrwxr-xr-x    1 dank  admin    52B Jan 29 13:11 utf8_and_gb18030.so -> ../Cellar/postgresql94/9.4.5/lib/utf8_and_gb18030.so
                            [dank:...clang_64/plugins/sqldrivers]$ l /usr/local/lib/ | grep mysql
                            lrwxr-xr-x    1 dank  admin    20B Feb  8 08:21 lib -> /usr/local/mysql/lib
                            lrwxr-xr-x    1 dank  admin    50B Feb  8 08:15 libmysqlclient.20.dylib -> ../Cellar/mysql/5.7.11/lib/libmysqlclient.20.dylib
                            lrwxr-xr-x    1 dank  admin    43B Feb  8 08:15 libmysqlclient.a -> ../Cellar/mysql/5.7.11/lib/libmysqlclient.a
                            lrwxr-xr-x    1 dank  admin    47B Feb  8 08:15 libmysqlclient.dylib -> ../Cellar/mysql/5.7.11/lib/libmysqlclient.dylib
                            lrwxr-xr-x    1 dank  admin    38B Feb  8 08:22 libmysqld-debug.a -> /usr/local/mysql/lib/libmysqld-debug.a
                            lrwxr-xr-x    1 dank  admin    38B Feb  8 08:15 libmysqld.a -> ../Cellar/mysql/5.7.11/lib/libmysqld.a
                            lrwxr-xr-x    1 dank  admin    45B Feb  8 08:15 libmysqlservices.a -> ../Cellar/mysql/5.7.11/lib/libmysqlservices.a
                            ...
                            

                            so I ran

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

                            to double check

                            [dank:...clang_64/plugins/sqldrivers]$ otool -L libqsqlmysql.dylib
                            libqsqlmysql.dylib:
                            	libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
                            	/usr/local/Cellar/mysql/5.7.11/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 1213.0.0)
                            

                            I feel the fact that it still says version 18.0.0 is weird but it works now for me

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              Day Reloader
                              wrote on 8 Aug 2017, 18:27 last edited by
                              #21

                              Hello SGiant, I am new to QT and have been trying to work with database using MYSQL for last few days, but am getting the same errors as others, i.e. "Driver not loaded Driver not loaded".
                              I tried copying libmysqlclient.20.dylib from ~/usr/local/Cellar/mysql/5.7.19/lib to ~/opt/local/lib/mysql55/mysql but nothing happened. (I don't know how to use install_name_tool).

                              Please help me out.
                              Thank You.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 8 Aug 2017, 21:34 last edited by
                                #22

                                Hi @Day-Reloader and welcome to devnet,

                                There's an example of how to use install_name_tool in this very thread in one of the answer of @Orbotron.

                                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
                                • ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on 29 May 2018, 11:15 last edited by
                                  #23

                                  I have a new problem. When I type "otool -L libqsqlmysql.dylib" in the terminal, the reply is /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: 'libqsqlmysql.dylib': No such file or directory
                                  However, the fact is I have the file "libqsqlmysql.dylib" in the sqldrivers.
                                  How do I solve this problem?

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 29 May 2018, 11:36 last edited by
                                    #24

                                    Hi and welcome to devnet,

                                    Either you have to be in the same folder as the file you want to analyse or pass the full path to it.

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

                                    ? 2 Replies Last reply 29 May 2018, 11:56
                                    0
                                    • S SGaist
                                      29 May 2018, 11:36

                                      Hi and welcome to devnet,

                                      Either you have to be in the same folder as the file you want to analyse or pass the full path to it.

                                      ? Offline
                                      ? Offline
                                      A Former User
                                      wrote on 29 May 2018, 11:56 last edited by
                                      #25

                                      @SGaist
                                      amazing!! I have finished that step. But what about the next step?
                                      I have searched the Internet about the some approaches to solve the driver problem, but I don't know which is correct.
                                      PLZ

                                      1 Reply Last reply
                                      0
                                      • S SGaist
                                        29 May 2018, 11:36

                                        Hi and welcome to devnet,

                                        Either you have to be in the same folder as the file you want to analyse or pass the full path to it.

                                        ? Offline
                                        ? Offline
                                        A Former User
                                        wrote on 29 May 2018, 12:19 last edited by
                                        #26

                                        @SGaist more details:
                                        ~/Qt/5.11.0/clang_64/plugins/sqldrivers  otool -L libqsqlmysql.dylib
                                        libqsqlmysql.dylib:
                                        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.0)
                                        @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.11.0, current version 5.11.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/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)

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on 29 May 2018, 20:24 last edited by
                                          #27

                                          The output looks nice. What is the problem ?

                                          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