0

I've tried for the past 4 hours to get the MySQL connection with Qt/C++. There are a bunch of posts but they just don't work for me.

I've seen a lot of guides where you just have to move the the .dll files to a certain folder, but they don't work. Some say like place the files inside MinGW/plugins/mysql but I don't even have those folders present.

Then I saw this guide: Create MySQL driver for Qt5 on Windows where you seem to have to build your own driver, and I'm also struggling with this; but, why is this needed? Why other guides and users claim that all you have to do is to copy the files to a specific folder? Is it because a certain version of Qt or MySQL is needed? Which one should I download?

Error I'm getting:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7

Actual setup:

  • Running Windows 10 64bits
  • Qt Creator 4.9.1 - I must have messed up something the last time I re-installed Qt a few mins ago, because now it shows MSVC2017, but I was actually trying with MinGW first...

Qt Creator version

  • MySQL 8.0.18

MySQL version

Thanks in advance.

2
  • Set QT_DEBUG_PLUGINS environment variable to 1 and attach the output debug information to your question. Commented Dec 4, 2019 at 6:10
  • Have you enabled the Qt SQL module in QT project settings ? Commented Dec 4, 2019 at 7:51

1 Answer 1

1

you can use this : https://github.com/thecodemonkey86/qt_mysql_driver/releases and find your Qt version then download your dll files and then add them to : C:\Qt\Qt version\mingw81_64\bin\ and C:\Qt\Qt version\mingw81_64\plugins\sqldrivers

after this you can run your project by Qt Creator

if you wanna use windeployqt.exe you should be add .dll files to your project directory

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.