Cant connect to mysql database: QMYSQL driver not loaded
-
Hi All,
I'm one step closer to my goal, I can now build the plugin. I cannot yet connect to my database.
Steps I've taken:- Download and install https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.11-win32.msi
- Add C:\Qt\Tools\mingw530_32\bin and C:\Qt\5.10.1\mingw53_32\bin to the path
- Open cmd.exe, and enter the following commands:
c:\Qt\5.10.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="c:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" MYSQL_LIBDIR="c:\Program Files (x86)\MySQL\MySQL Connector C 6.1"\lib Running configuration tests... Checking for DB2 (IBM)... no Checking for InterBase... no Checking for MySQL... yes Checking for OCI (Oracle)... no Checking for ODBC... yes Checking for PostgreSQL... no Checking for SQLite (version 2)... no Checking for TDS (Sybase)... no Done running configuration tests. Configure summary: Qt Sql: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. yes OCI (Oracle) ........................... no ODBC ................................... yes PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt is now configured for building. Just run 'mingw32-make'. Once everything is built, Qt is installed. You should NOT run 'mingw32-make install'. Note that this build cannot be deployed to other machines or devices. Prior to reconfiguration, make sure you remove any leftovers from the previous build. mingw32-make <<lots of text>>
- Create a new Qt program, with the following options:
Qt widgets application
Name: sqlTest
Kit: Desktop Qt 5.11.1 MinGB 32 bit (default)
ClassName: (MainWindow) (default)
Version control: Git
QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = sqlTest TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QtSql> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("world"); db.setUserName("root"); db.setPassword("PassOlyForForumQuestion"); bool ok = db.open(); qDebug()<<ok; } MainWindow::~MainWindow() { delete ui; }
Program output:
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 false
Cheers,
Cedric@cdwijs said in Cant connect to mysql database: QMYSQL driver not loaded:
Hi All,
I'm one step closer to my goal, I can now build the plugin. I cannot yet connect to my database.
Steps I've taken:- Download and install https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.11-win32.msi
- Add C:\Qt\Tools\mingw530_32\bin and C:\Qt\5.10.1\mingw53_32\bin to the path
Hi,
I am struggling with the same issue, where exactly did you add C:\Qt\Tools\mingw530_32\bin and C:\Qt\5.10.1\mingw53_32\bin to? -
@cdwijs said in Cant connect to mysql database: QMYSQL driver not loaded:
Hi All,
I'm one step closer to my goal, I can now build the plugin. I cannot yet connect to my database.
Steps I've taken:- Download and install https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.11-win32.msi
- Add C:\Qt\Tools\mingw530_32\bin and C:\Qt\5.10.1\mingw53_32\bin to the path
Hi,
I am struggling with the same issue, where exactly did you add C:\Qt\Tools\mingw530_32\bin and C:\Qt\5.10.1\mingw53_32\bin to?@hobbyProgrammer I've added them to the PATH. On widows7, you can find that setting here:
start->control panel->system and security->system->Advanced system settings->Advanced->Environment Variables->System variables->Path->Edit...You can see the current value of the path variable by start->run->cmd and the command:
echo %PATH% -
@hobbyProgrammer I've added them to the PATH. On widows7, you can find that setting here:
start->control panel->system and security->system->Advanced system settings->Advanced->Environment Variables->System variables->Path->Edit...You can see the current value of the path variable by start->run->cmd and the command:
echo %PATH%@cdwijs thanks, but unfortunately it didn't work for me :(
-
@cdwijs thanks, but unfortunately it didn't work for me :(
@hobbyProgrammer Did you log out and log in after changing PATH?
-
@hobbyProgrammer Did you log out and log in after changing PATH?
@jsulm open the cmd again or log out as a computer user?
-
@jsulm open the cmd again or log out as a computer user?
@hobbyProgrammer Log out as user and login again, then check in terminal as @cdwijs suggested.
-
@jsulm open the cmd again or log out as a computer user?
@hobbyProgrammer
In the time it takes to wait for an answer, and in order to be simply confident everything sees the new environment variable, isn't it just quicker to completely log out & in or even reboot and then you know for sure where you are?! -
This post is deleted!
-
Hello,
I have gone through the same issue. there are 2 libmysql.dll libraries version. One for 32 and the other for 64 bits.
These 2 files are both available inhere :
https://www.dll-files.com/libmysql.dll.htmlI advise you to do the following.
-
create a folder in the C drive and name it as you wish and set the PATH to include that folder.
-
Step number 2, reload your system.
-
Step number 3 copy one of the 2 files libmysql.dll in that folder and try to run your binary if this doesnt work then try the second one.
This should work!
have a good day!
-
-
Hello,
I have gone through the same issue. there are 2 libmysql.dll libraries version. One for 32 and the other for 64 bits.
These 2 files are both available inhere :
https://www.dll-files.com/libmysql.dll.htmlI advise you to do the following.
-
create a folder in the C drive and name it as you wish and set the PATH to include that folder.
-
Step number 2, reload your system.
-
Step number 3 copy one of the 2 files libmysql.dll in that folder and try to run your binary if this doesnt work then try the second one.
This should work!
have a good day!
@Back2coding downloading .dlls from 3rd party website like that is usually a bad idea. You do not know what might lurk in there.
-