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

QSqlDatabase: QMYSQL driver not loaded ubuntu, Qt5.14.0

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 5 Posters 6.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.
  • S Offline
    S Offline
    sujith D
    wrote on last edited by
    #1

    I am new to Qt trying to integrate mysql with qt
    but unfortunately showing this error

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    open fail
    "Driver not loaded"

    I followed this documentation https://doc.qt.io/qt-5/sql-driver.html#qmysql

    /Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers# qmake -- MYSQL_PREFIX=/usr/local

    Running configuration tests...
    Done running configuration tests.

    Configure summary:

    Qt Sql Drivers:
    DB2 (IBM) .............................. no
    InterBase .............................. no
    MySql .................................. yes
    OCI (Oracle) ........................... no
    ODBC ................................... no
    PostgreSQL ............................. no
    SQLite2 ................................ no
    SQLite ................................. yes
    Using system provided SQLite ......... no
    TDS (Sybase) ........................... no

    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into '/usr'.

    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.

    /Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers# make sub-mysql

    cd mysql/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/sujith/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro MYSQL_PREFIX=/usr/local ) && make -f Makefile
    make[1]: Entering directory '/home/sujith/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/mysql'
    make[1]: Nothing to be done for 'first'.
    make[1]: Leaving directory '/home/sujith/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/mysql'

    /home/sujith/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/mysql# make -f Makefile
    make: Nothing to be done for 'first'.

    Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/mysql# make install
    /usr/lib/qt5/bin/qmake -install qinstall -exe ../plugins/sqldrivers/libqsqlmysql.so /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so
    /usr/lib/qt5/bin/qmake -install qinstall /home/sujith/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/lib/cmake/Qt5Sql/Qt5Sql_QMYSQLDriverPlugin.cmake /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql/Qt5Sql_QMYSQLDriverPlugin.cmake
    root@sujith-HP-Notebook:/home/sujith/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/mysql#

    I can't figure out where I am missing.

    1 Reply Last reply
    0
    • eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #17

      @sujith-D Execute:

      cd ~/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers && ~/Qt5.14.0/5.14.0/gcc_64/bin/qmake sqldrivers.pro && make && make install
      
      S 1 Reply Last reply
      5
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Did you install your custom built plugin ?

        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
        • S Offline
          S Offline
          sujith D
          wrote on last edited by sujith D
          #3

          @SGaist Is that described in this doc https://doc.qt.io/qt-5/sql-driver.html#qmysql ?
          can you tell me how to make custom built plugin for mysql in ubuntu ?

          M 1 Reply Last reply
          0
          • S sujith D

            @SGaist Is that described in this doc https://doc.qt.io/qt-5/sql-driver.html#qmysql ?
            can you tell me how to make custom built plugin for mysql in ubuntu ?

            M Offline
            M Offline
            mvsri
            wrote on last edited by
            #4

            @sujith-D i got the same problem when i tried to link MYSQL with QT in Ubuntu 16.04.
            I tried this solution and it worked for me.
            Mysql Linking

            1 Reply Last reply
            2
            • S Offline
              S Offline
              sujith D
              wrote on last edited by sujith D
              #5

              @mvsri Thanks for the reply
              sudo apt-get install libqt5sql5-mysql
              Reading package lists... Done
              Building dependency tree
              Reading state information... Done
              libqt5sql5-mysql is already the newest version (5.12.2+dfsg-4ubuntu1.1).
              The following packages were automatically installed and are no longer required:
              libdumbnet1 php7.3-dev
              Use 'sudo apt autoremove' to remove them.
              0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

              1 Reply Last reply
              0
              • Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @sujith-D said in QSqlDatabase: QMYSQL driver not loaded ubuntu, Qt5.14.0:

                I can't figure out where I am missing.

                There is nothing missing - all is fine as you can see:

                /usr/lib/qt5/bin/qmake -install qinstall -exe ../plugins/sqldrivers/libqsqlmysql.so /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so

                The plugin is now correctly installed for your custom Qt5.14.0 installation

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                2
                • S Offline
                  S Offline
                  sujith D
                  wrote on last edited by sujith D
                  #7

                  @Christian-Ehrlicher But unfortunately when I run my code it shows this error

                  QSqlDatabase: QMYSQL driver not loaded
                  QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
                  open fail
                  "Driver not loaded"

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    Ah sorry, you did something wrong.
                    You called the wrong qmake executable so it was installed into your system Qt installation. You have to remove config.cache, and run the correct qmake (from where you installed Qt 5.14.0 into)

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    3
                    • S Offline
                      S Offline
                      sujith D
                      wrote on last edited by sujith D
                      #9

                      @Christian-Ehrlicher said in QSqlDatabase: QMYSQL driver not loaded ubuntu, Qt5.14.0:

                      qmake

                      Bro how to remove the config cache, and how to run correct qmake , if my qt installed path is /home/sujith/Qt5.14.0/5.14.0/Src/

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

                        How to remove: delete the file/folder using for example rm.

                        For qmake, use the full path to the executable you want to call.

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

                        S 1 Reply Last reply
                        2
                        • SGaistS SGaist

                          How to remove: delete the file/folder using for example rm.

                          For qmake, use the full path to the executable you want to call.

                          S Offline
                          S Offline
                          sujith D
                          wrote on last edited by sujith D
                          #11

                          @SGaist Sorry. Do to lack of experience, I don't know which is the config cache folder to remove can you specify the folder name to remove and also how to run the qmake with full path. please help me.

                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Online
                            Christian EhrlicherC Online
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by Christian Ehrlicher
                            #12

                            The config.cache file is create by qmake in /Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers - you simply could have take a look there to find it.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            S 1 Reply Last reply
                            4
                            • Christian EhrlicherC Christian Ehrlicher

                              The config.cache file is create by qmake in /Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers - you simply could have take a look there to find it.

                              S Offline
                              S Offline
                              sujith D
                              wrote on last edited by
                              #13

                              Thanks found /home/sujith/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/config.cache
                              rm /home/sujith/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers/config.cache ?
                              then again qmake -- MYSQL_PREFIX= fullpath ?
                              how to find fullpath ?

                              1 Reply Last reply
                              0
                              • Christian EhrlicherC Online
                                Christian EhrlicherC Online
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #14

                                @sujith-D said in QSqlDatabase: QMYSQL driver not loaded ubuntu, Qt5.14.0:

                                how to find fullpath ?

                                you should know where you installed your Qt5.14. installation into, so you can also find the correct qmake in there - we don't know where you installed your Qt5.14 binary files (your comment about /home/sujith/Qt5.14.0/5.14.0/Src is wrong - at least I don't think that you installed your binary files into the source dir)

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                1 Reply Last reply
                                3
                                • eyllanescE Offline
                                  eyllanescE Offline
                                  eyllanesc
                                  wrote on last edited by eyllanesc
                                  #15
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    sujith D
                                    wrote on last edited by
                                    #16

                                    ok bro 1mnt I will try

                                    1 Reply Last reply
                                    0
                                    • eyllanescE Offline
                                      eyllanescE Offline
                                      eyllanesc
                                      wrote on last edited by
                                      #17

                                      @sujith-D Execute:

                                      cd ~/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers && ~/Qt5.14.0/5.14.0/gcc_64/bin/qmake sqldrivers.pro && make && make install
                                      
                                      S 1 Reply Last reply
                                      5
                                      • eyllanescE eyllanesc

                                        @sujith-D Execute:

                                        cd ~/Qt5.14.0/5.14.0/Src/qtbase/src/plugins/sqldrivers && ~/Qt5.14.0/5.14.0/gcc_64/bin/qmake sqldrivers.pro && make && make install
                                        
                                        S Offline
                                        S Offline
                                        sujith D
                                        wrote on last edited by
                                        #18

                                        @eyllanesc Thank you bro. You saved my week.

                                        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