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. QSqlDatabase: QMYSQL driver not loaded

QSqlDatabase: QMYSQL driver not loaded

Scheduled Pinned Locked Moved Solved Installation and Deployment
7 Posts 2 Posters 943 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.
  • _ Offline
    _ Offline
    _VA0
    wrote on last edited by SGaist
    #1

    I realize that this topic has been covered but I'm not sure exactly how I need to solve it on my system.
    I try to use SQL in Qt and get the following error:

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

    I am running on MacOS High Sierra(10.13.6). I have mysql installed with homebrew.

    From looking through other posts about this I need to run an otool -L libqsqlmysql.dylib.

    When I do that I get the following:

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

    Homebrew installed mysql here

    /usr/local/Cellar/mysql/8.0.15/lib
    

    which contains:

    libmysqlclient.21.dylib	libmysqlharness.a	libmysqlservices.a
    libmysqlclient.a	libmysqlharness.dylib	mysqlrouter
    libmysqlclient.dylib	libmysqlrouter.1.dylib	pkgconfig
    libmysqlharness.1.dylib	libmysqlrouter.dylib	plugin
    

    From what I've read I need to run a install_name_tool command with the '-change' flag. However , if that is what I need to do, I am not sure what I need to change to what. Can anyone offer any advice?

    [edit: Fixed coding tags SGaist]

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

      Hi and welcome to devnet,

      You are right, this question has been asked already a high number of time and answered also on this forum just as much.

      You need to change the path pointing to the MySQL dylib and change it to the one you have 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

      1 Reply Last reply
      1
      • _ Offline
        _ Offline
        _VA0
        wrote on last edited by
        #3

        Thanks for fixing my coding flags. That was my first time posting and It and left for work but then checked it on mobile and realized how horrible it looked and couldn't figure out how to fix them on mobile.

        So is the command I am looking for:

        install_name_tool -change /usr/local/mysql/lib/libmysqlclient.20.dylib /usr/local/Cellar/mysql/8.0.15/lib/libmysqlclient.dylib libqmysql.dylib

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

          No problem, they can be tricky.

          That's the correct line indeed.

          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
          • _ Offline
            _ Offline
            _VA0
            wrote on last edited by
            #5

            @SGaist Oh great! It's working! Thank you so much!

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

              You're welcome !

              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
              1
              • SGaistS SGaist

                You're welcome !

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

                _ Offline
                _ Offline
                _VA0
                wrote on last edited by
                #7

                @SGaist Sure thing;

                Also, so if anyone else comes across this with a similar issue, i should mention that my command was somewhat off, but barely. The exact command was

                install_name_tool -change /usr/local/mysql/lib/libmysqlclient.20.dylib /usr/local/Cellar/mysql/8.0.15/lib/libmysqlclient.dylib libqsqlmysql.dylib

                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