Unsolved Qt5 MYSQL plugin on Ubuntu 18.04 not working
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.
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
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.
@Menre 'that came with the installation'
Which installation? The distribution? From Qt online installer? Self compiled?
What I did was go to there website and I downloaded
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?
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.
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.
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.
JonB last edited by JonB
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