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. Qt5 MYSQL plugin on Ubuntu 18.04 not working

Qt5 MYSQL plugin on Ubuntu 18.04 not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.0k 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.
  • M Offline
    M Offline
    Menre
    wrote on last edited by
    #1

    Hello everyone,

    Please read my post carefully and find time to help me with a solution.
    I am learning how to connect to MYSQL DATABASE in Qt5. It has not been easy and I have not been successful so far. I tried it before on Windows and I could not get it to work after weeks of wasted effort. So, I switched to Ubuntu (Linux) and the problem remains. The error message that I am getting is the same. You can see it below.

    "QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    Database Connection Failed."

    MYSQL is not even listed as part of the available drivers. I will appreciate your effort please. I have done a lot of searching on the internet, but without luck so far.
    I did not build my Qt myself. I just used the command line installation on Ubuntu to install it. Everything else is fine except this database part of it.

    I will really appreciate your help.

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Menre said in Qt5 MYSQL plugin on Ubuntu 18.04 not working:

      MYSQL is not even listed as part of the available drivers.

      What Qt version do you use? The one provided by the distribution or a prebuild one from Qt? If from the distribution then you either forgot to install the qt-mysql package (or it's no longer provided), if you use a prebuild one you have to compile to plugin by your own: https://doc-snapshots.qt.io/qt5-5.14/sql-driver.html

      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
      • M Offline
        M Offline
        Menre
        wrote on last edited by
        #3

        Thanks for your response. I am using the one that came with the installation. As for the version that I am using, I have the information about it below for you to look at. please.

        Qt 5.13.2 GCC 64bit

        Qt Creator 4.10.1
        Based on Qt 5.13.1 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)

        Built on Oct 4 2019 04:22:26

        From revision ea829fa6d5

        Copyright 2008-2019 The Qt Company Ltd. All rights reserved.

        Christian EhrlicherC 1 Reply Last reply
        0
        • M Menre

          Thanks for your response. I am using the one that came with the installation. As for the version that I am using, I have the information about it below for you to look at. please.

          Qt 5.13.2 GCC 64bit

          Qt Creator 4.10.1
          Based on Qt 5.13.1 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)

          Built on Oct 4 2019 04:22:26

          From revision ea829fa6d5

          Copyright 2008-2019 The Qt Company Ltd. All rights reserved.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Menre 'that came with the installation'

          Which installation? The distribution? From Qt online installer? Self compiled?

          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
          0
          • M Offline
            M Offline
            Menre
            wrote on last edited by
            #5

            What I did was go to there website and I downloaded
            qt-opensource-linux-x64-5.13.2.run

            Then I run it from the linux command line to install it. So, what do we call that process please? Online installer or self compiled?

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

              Then you have to compile the mysql plugin by yourself: https://doc-snapshots.qt.io/qt5-5.14/sql-driver.html

              So, what do we call that process please? Online installer or self compiled?

              online installer - you did not compile Qt by your own.

              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
              0
              • M Offline
                M Offline
                Menre
                wrote on last edited by
                #7

                The instructions on the link that you sent me do not work for me. They are very confusing to understand. Is there no easy way to 'build the MYSQL driver for Qt5 on ubuntu 18.04'? A detail search on the internet shows that this is a major problem that developers encounter with qt and mysql when it comes to database working with qt.

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

                  @Menre said in Qt5 MYSQL plugin on Ubuntu 18.04 not working:

                  The instructions on the link that you sent me do not work for me. They are very confusing to understand

                  What exactly did not work - 'does not work' is not really helpful...

                  Is there no easy way t

                  Use the Qt provided by your distribution and hope that they provide a pre-compiled plugin. Otherwise blame MySQL for their licensing.

                  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
                  0
                  • M Menre

                    Hello everyone,

                    Please read my post carefully and find time to help me with a solution.
                    I am learning how to connect to MYSQL DATABASE in Qt5. It has not been easy and I have not been successful so far. I tried it before on Windows and I could not get it to work after weeks of wasted effort. So, I switched to Ubuntu (Linux) and the problem remains. The error message that I am getting is the same. You can see it below.

                    "QSqlDatabase: QMYSQL driver not loaded
                    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
                    Database Connection Failed."

                    MYSQL is not even listed as part of the available drivers. I will appreciate your effort please. I have done a lot of searching on the internet, but without luck so far.
                    I did not build my Qt myself. I just used the command line installation on Ubuntu to install it. Everything else is fine except this database part of it.

                    I will really appreciate your help.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @Menre
                    I always use the Qt associated with my Ubuntu release, fetched via apt-get. I never compile Qt. I get the right stuff, and all works fine, including in Ubuntu 18.04 with MySQL in the past. Before you go any further, do you have a reason for wanting to compile your own version, or would you be happy with the one released with Ubuntu 18.04?

                    The stuff I install includes (I am Python/PyQt5 & Ubuntu 19.04, but it will give you an idea for C++/18.04, it includes MySQL stuff):

                    sudo apt-get install qtcreator
                    sudo apt-get install qt5-default
                    sudo apt-get install python3-pyqt5.qtsql python3-pyqt5.qtsql-dbg
                    sudo apt-get install python3-mysql.connector
                    sudo apt-get install libqt5sql5-mysql
                    
                    1 Reply Last reply
                    2

                    • Login

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