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
Forum Updated to NodeBB v4.3 + New Features

QSqlDatabase: QMYSQL driver not loaded

Scheduled Pinned Locked Moved Solved General and Desktop
qmysqlqsqldatabaseubuntu 14.04driver not load
28 Posts 6 Posters 28.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.
  • jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #8

    That's probably the problem:
    libmysqlclient_r.so.16 => not found

    It looks like the MySQL lib is not installed.

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

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tas-sos
      wrote on last edited by
      #9

      what can I do to fix it?

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

        Can you check whether you have libmysqlclient_r.so.16 on your system?
        On my Ubuntu 14.04 it is libmysqlclient_r.so.18

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

        T 1 Reply Last reply
        0
        • jsulmJ jsulm

          Can you check whether you have libmysqlclient_r.so.16 on your system?
          On my Ubuntu 14.04 it is libmysqlclient_r.so.18

          T Offline
          T Offline
          Tas-sos
          wrote on last edited by
          #11

          @jsulm
          Yes I have the same too :

          :/usr/lib/i386-linux-gnu$ ls | grep libmysql
          libmysqlclient.a
          libmysqlclient_r.a
          libmysqlclient_r.so
          libmysqlclient_r.so.18
          libmysqlclient_r.so.18.0.0
          libmysqlclient.so
          libmysqlclient.so.18
          libmysqlclient.so.18.0.0
          
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #12

            Then the easiest way is to rebuild the plugin against your installed MySQL client libraries. It's described here

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

            T 1 Reply Last reply
            0
            • SGaistS SGaist

              Then the easiest way is to rebuild the plugin against your installed MySQL client libraries. It's described here

              T Offline
              T Offline
              Tas-sos
              wrote on last edited by
              #13

              @SGaist
              Could someone please guide me?
              This guide does not help that much.. :/

              There is no other way?

              1 Reply Last reply
              0
              • hskoglundH Offline
                hskoglundH Offline
                hskoglund
                wrote on last edited by
                #14

                Hi, you could try to trick Qt you've got the correct file, by using the newer version as the older one (just a guess :-):
                cp libmysqlclient_r.so.18.0.0 libmysqlclient_r.so.16

                T 1 Reply Last reply
                0
                • hskoglundH hskoglund

                  Hi, you could try to trick Qt you've got the correct file, by using the newer version as the older one (just a guess :-):
                  cp libmysqlclient_r.so.18.0.0 libmysqlclient_r.so.16

                  T Offline
                  T Offline
                  Tas-sos
                  wrote on last edited by
                  #15

                  @hskoglund
                  I tried to shortcut and copy as you say now.
                  but the same effect :

                  code :

                      QPluginLoader loader;
                      loader.setFileName("/home/myuser/Qt/5.4/gcc/plugins/sqldrivers/libqsqlmysql.so");
                      qDebug() << "PluginLoader worked =" << loader.load();
                      qDebug() << "Plugin Loader error=" << loader.errorString();
                  

                  error :

                  PluginLoader worked = false
                  Plugin Loader error= "Cannot load library /home/myuser/Qt/5.4/gcc/plugins/sqldrivers/libqsqlmysql.so: (/usr/lib/i386-linux-gnu/libmysqlclient_r.so.16: version `libmysqlclient_16' not found (required by /home/myuser/Qt/5.4/gcc/plugins/sqldrivers/libqsqlmysql.so))"
                  
                  1 Reply Last reply
                  0
                  • hskoglundH Offline
                    hskoglundH Offline
                    hskoglund
                    wrote on last edited by
                    #16

                    Ok, maybe you need to go further tricking Qt also that the libmysqlclient.so.16 is fine and well, by also copying that file:
                    cp libmysqlclient.so.18.0.0 libmysqlclient.so.16

                    T 1 Reply Last reply
                    0
                    • hskoglundH hskoglund

                      Ok, maybe you need to go further tricking Qt also that the libmysqlclient.so.16 is fine and well, by also copying that file:
                      cp libmysqlclient.so.18.0.0 libmysqlclient.so.16

                      T Offline
                      T Offline
                      Tas-sos
                      wrote on last edited by
                      #17

                      @hskoglund
                      oops you're right! I had not noticed the name. But now? I have this error :

                      PluginLoader worked = false
                      Plugin Loader error= "Cannot load library /home/myuser/Qt/5.4/gcc/plugins/sqldrivers/libqsqlmysql.so: (/usr/lib/i386-linux-gnu/libmysqlclient_r.so.16: version `libmysqlclient_16' not found (required by /home/myuser/Qt/5.4/gcc/plugins/sqldrivers/libqsqlmysql.so))"
                      

                      and these files :

                      :/usr/lib/i386-linux-gnu$ ls | grep libmysql
                      libmysqlclient.a
                      libmysqlclient_r.a
                      libmysqlclient_r.so
                      libmysqlclient_r.so.16
                      libmysqlclient_r.so.18
                      libmysqlclient_r.so.18.0.0
                      libmysqlclient.so
                      libmysqlclient.so.16
                      libmysqlclient.so.18
                      libmysqlclient.so.18.0.0
                      
                      
                      1 Reply Last reply
                      0
                      • hskoglundH Offline
                        hskoglundH Offline
                        hskoglund
                        wrote on last edited by
                        #18

                        Ahhh, sorry it seems the ruse didn't work all the way :-(
                        It's probably a version resource or something simular in the libmysqlclient.so.18.0.0 file that says "version 18" and not "version 16".

                        Anyway I think your next step is instead to try to download and install the kosher *.16, have you tried?
                        sudo apt-get install libmysqlclient16

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

                          You can't cheat like that on Linux ;)

                          @Tas-sos what trouble did you have to rebuild the plugin ? It's really just grab Qt's source and follow the lines of the documentation.

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

                          T 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            You can't cheat like that on Linux ;)

                            @Tas-sos what trouble did you have to rebuild the plugin ? It's really just grab Qt's source and follow the lines of the documentation.

                            T Offline
                            T Offline
                            Tas-sos
                            wrote on last edited by Tas-sos
                            #20

                            @hskoglund

                            Never mind my friend anyway thank you very much!
                            Yes I have tried it and got this:

                            E: Unable to locate the package libmysqlclient16
                            

                            or this :

                            E: Unable to locate the package libmysqlclient16-dev
                            

                            @SGaist
                            xaxaax my friend like your answer.
                            "You can't cheat like that on Linux ;)"

                            As for the guide (documentation) , basically confuses me a little and I do not know if I can follow him because for example he says to run this command :

                            cd $QTDIR/qtbase/src/plugins/sqldrivers/mysql
                            

                            But me the file structure is :

                            :~$ ls Qt 
                            5.4
                            components.xml
                            Docs
                            Examples
                            Extras
                            InstallationLog.txt
                            Licenses
                            MaintenanceTool
                            MaintenanceTool.dat
                            MaintenanceTool.ini
                            network.xml
                            Tools
                            
                            :~/Qt/5.4$ ls
                            android_armv7  gcc
                            
                            :~/Qt/5.4/gcc$ ls
                            bin
                            icudtl.dat
                            imports
                            include
                            lib
                            libexec
                            mkspecs
                            phrasebooks
                            plugins
                            qml
                            qtwebengine_resources.pak
                            translations
                            
                            :~/Qt/5.4/gcc/plugins$ ls -l
                            
                            audio
                            bearer
                            designer
                            generic
                            geoservices
                            iconengines
                            imageformats
                            mediaservice
                            platforminputcontexts
                            platforms
                            platformthemes
                            playlistformats
                            position
                            printsupport
                            qml1tooling
                            qmltooling
                            qtwebengine
                            sensorgestures
                            sensors
                            sqldrivers  <-----------
                            
                            :~/Qt/5.4/gcc/plugins$ tree sqldrivers/
                            sqldrivers/
                            ├── libqsqlite.so
                            ├── libqsqlmysql.so
                            └── libqsqlpsql.so
                            

                            the path that says, to me (as you see) does not exist. :/
                            Extra searches:

                            find  ~/Qt -name "sqldrivers"
                            /home/myuser/Qt/Tools/QtCreator/bin/plugins/sqldrivers
                            /home/myuser/Qt/5.4/gcc/plugins/sqldrivers
                            
                            $find  ~/Qt -name "qtbase"
                            -nothing-
                            
                            $ find  ~/Qt -name "mysql"
                            -nothing-
                            

                            In my system the folders with name "mysql" are only those :

                            sudo find  / -name "mysql"
                            /var/lib/mysql
                            /var/lib/mysql/mysql
                            /var/log/mysql
                            /etc/apparmor.d/abstractions/mysql
                            /etc/init.d/mysql
                            /etc/mysql
                            /usr/bin/mysql
                            /usr/lib/perl5/auto/DBD/mysql
                            /usr/lib/perl5/DBD/mysql
                            /usr/lib/mysql
                            /usr/share/maven-repo/mysql
                            /usr/share/mysql
                            /usr/share/bash-completion/completions/mysql
                            /usr/include/mysql
                            /usr/include/mysql/mysql
                            

                            and folder named "qtbase" does not exist.
                            For this reason the documentation does not help.

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

                              That's because you don't have the Qt sources installed. Use maintenancetool to download them.

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

                              T chawilaC 2 Replies Last reply
                              1
                              • SGaistS SGaist

                                That's because you don't have the Qt sources installed. Use maintenancetool to download them.

                                T Offline
                                T Offline
                                Tas-sos
                                wrote on last edited by
                                #22

                                @SGaist
                                Unbelievable though it was in front of me I had no idea about the "maintenancetool". I am inexperienced with using Qt not know so much about this, but I hope now to learn.

                                I ran as you said the "MaintenanceTool" located in the "Qt" folder and i installed the "sources".
                                Then I have what I needed! :D

                                The guide now is satisfactory and effective. ;)

                                Simply the guide says this path:

                                cd $QTDIR/qtbase/src/plugins/sqldrivers/mysql
                                

                                to me is this:

                                /home/myuser/Qt/5.4/Src/qtbase/src/plugins/sqldrivers/mysql
                                

                                Then because I have and version "Qt4" this command:

                                qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
                                

                                i run in this way:

                                /home/myuser/Qt/5.4/gcc/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
                                

                                All now work perfectly! I'm very happy about that! I Struggled a lot with this issue and does not need nor expecting.
                                Thank you very very much my friends! I am indebted to your with your efficient and fast help!

                                THANK YOU!

                                chawilaC G 2 Replies Last reply
                                0
                                • T Tas-sos

                                  @SGaist
                                  Unbelievable though it was in front of me I had no idea about the "maintenancetool". I am inexperienced with using Qt not know so much about this, but I hope now to learn.

                                  I ran as you said the "MaintenanceTool" located in the "Qt" folder and i installed the "sources".
                                  Then I have what I needed! :D

                                  The guide now is satisfactory and effective. ;)

                                  Simply the guide says this path:

                                  cd $QTDIR/qtbase/src/plugins/sqldrivers/mysql
                                  

                                  to me is this:

                                  /home/myuser/Qt/5.4/Src/qtbase/src/plugins/sqldrivers/mysql
                                  

                                  Then because I have and version "Qt4" this command:

                                  qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
                                  

                                  i run in this way:

                                  /home/myuser/Qt/5.4/gcc/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
                                  

                                  All now work perfectly! I'm very happy about that! I Struggled a lot with this issue and does not need nor expecting.
                                  Thank you very very much my friends! I am indebted to your with your efficient and fast help!

                                  THANK YOU!

                                  chawilaC Offline
                                  chawilaC Offline
                                  chawila
                                  wrote on last edited by
                                  #23
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • SGaistS SGaist

                                    That's because you don't have the Qt sources installed. Use maintenancetool to download them.

                                    chawilaC Offline
                                    chawilaC Offline
                                    chawila
                                    wrote on last edited by
                                    #24

                                    @SGaist said in QSqlDatabase: QMYSQL driver not loaded:

                                    That's because you don't have the Qt sources installed. Use maintenancetool to download them.

                                    Can someone tell please me what are QT sources..

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

                                      Hi,

                                      As silly as it may sound: that's the sources of the Qt library.

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

                                        Can you run ldd on Qt's MySQL plugin ?

                                        chawilaC Offline
                                        chawilaC Offline
                                        chawila
                                        wrote on last edited by
                                        #26
                                        This post is deleted!
                                        1 Reply Last reply
                                        0
                                        • T Tas-sos

                                          @SGaist
                                          Unbelievable though it was in front of me I had no idea about the "maintenancetool". I am inexperienced with using Qt not know so much about this, but I hope now to learn.

                                          I ran as you said the "MaintenanceTool" located in the "Qt" folder and i installed the "sources".
                                          Then I have what I needed! :D

                                          The guide now is satisfactory and effective. ;)

                                          Simply the guide says this path:

                                          cd $QTDIR/qtbase/src/plugins/sqldrivers/mysql
                                          

                                          to me is this:

                                          /home/myuser/Qt/5.4/Src/qtbase/src/plugins/sqldrivers/mysql
                                          

                                          Then because I have and version "Qt4" this command:

                                          qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
                                          

                                          i run in this way:

                                          /home/myuser/Qt/5.4/gcc/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
                                          

                                          All now work perfectly! I'm very happy about that! I Struggled a lot with this issue and does not need nor expecting.
                                          Thank you very very much my friends! I am indebted to your with your efficient and fast help!

                                          THANK YOU!

                                          G Offline
                                          G Offline
                                          Gualtix
                                          wrote on last edited by Gualtix
                                          #27

                                          @SGaist @Tas-sos Im just Right where you are, usgin make... put i have this error:
                                          'MySql Lib is Not Defined'

                                          0_1558483350957_f0fa2c95-6be7-4055-8355-c23fad355ed9-image.png

                                          Help Please!!!

                                          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