QSqlDatabase: QMYSQL driver not loaded
-
Hi, the output looks good, only one more step should remain, you need to copy the mysql driver dll to the same folder as where your app .exe file is.
The driver dll file is called libmysql.dll and it should be in the C:\Program Files\MySQL\MySQL Server 8.0\lib (provided that you've installed the 64-bit MySQL Installer 8.0.22)
So if I'm guessing correctly then the copy command is:
copy "C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.dll" C:\Users\user\Documents\CP\build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Release\release
If you cannot find it (or haven't installed the MyQSL Installer) then there are plenty of alternatives for downloading that libmysql.dll file, for example here
-
Hi, even though you successfully copied libmysql.dll to where your .exe file is, perhaps it still fails because the .dlls that libmysql.dll depend on are not in your path. The files are libssl-1_1-x64.dll and libcrypto-1_1-x64.dll.
They also need to be copied to the same directory where your .exe file is, try (note: I'm guessing where they are on your PC):
copy C:\mysql-8.0.22-winx64\lib\libssl-1_1-x64.dll C:\Users\user\Documents\CP\build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Release\release
and
copy C:\mysql-8.0.22-winx64\lib\libcrypto-1_1-x64.dll C:\Users\user\Documents\CP\build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Release\release
P.S. If it still fails, could you post a directory listing of the files in the directory where your .exe file is, I'm guessing it is: C:\Users\user\Documents\CP\build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Release\release?
Edit: googled a bit more, there's an easier way to fix those 2 missing .dlls: install the MySQL Community Downloads MySQL Installer for Windows It's free but it requires an Oracle login :-( but perhaps you already have one)
-
Hi, looks good, but to check you've got the right versions, please also provide:
the path of the folder, for example C:\Users\user\Documents\CP\build-DatabaseConnection-Desktop_Qt_6_4_0_MSVC2019_64bit-Release\release
the times and dates of all the files in the folder
the sizes in bytes of all the files in the folder -
@hskoglund Hey I am sorry for replying so late. Here goes:
DatabaseConnection.exe 18.06.2022 18:22 28 KB
libcrypto-1_1-x64.dll 16.03.2022 09:45 2.803 KB
libmysql.dll 16.06.2020 20:53 6.647 KB
libssl-1_1-x64.dll 16.03.2022 09:45 671 KB
main.obj 18.06.2022 18:22 7KB
mainwindow.obj 18.06.2022 18:22 29 KB
moc_mainwindow.cpp 18.06.2022 18:22 3 KB
moc_mainwindow.obj 18.06.2022 18:22 4 KB
moc_predefs.h 18.06.2022 18:22 1KBThe path to the files is exactly what is in your comment.
I look forward to your reaction.
thanks in advance. -
Hi, libmysql.dll is not from the same year as libcrypto-1_1-x64.dll and ibssl-1_1-x64.dll, that could be a problem. I don't think that's the reason for the error though.
I think you need to use a version of Qt that is not a beta release but a "real" release. That means installing the Qt 6.3.1 MSVC 2019 64-bit version. Then rebuild your app with that version of Qt.
To avoid rebuilding the MySQL plugin for Qt version 6.3.1 you can download it from here
When you open the zip, place the3 files libcrypto-1_1-x64.dll, libmysql.dll and libssl-1_1-x64.dll in the same folder as your .exe file (I'm guessing C:\Users\user\Documents\CP\build-DatabaseConnection-Desktop_Qt_6_3_1_MSVC2019_64bit-Release\release)
then open the subdirectory sqldrivers in the .zip file and copy the 2 files qsqlmysql.dll and qsqlmysqld.dll to the plugins folder of your newly installed Qt version 6.3.1, I'm guessing: C:\Qt\6.3.1\msvc2019_64\plugins\sqldrivers -
@hskoglund said in QSqlDatabase: QMYSQL driver not loaded:
Hi, libmysql.dll is not from the same year as libcrypto-1_1-x64.dll and ibssl-1_1-x64.dll, that could be a problem. I don't think that's the reason for the error though.
I think you need to use a version of Qt that is not a beta release but a "real" release. That means installing the Qt 6.3.1 MSVC 2019 64-bit version. Then rebuild your app with that version of Qt.
To avoid rebuilding the MySQL plugin for Qt version 6.3.1 you can download it from here
When you open the zip, place the3 files libcrypto-1_1-x64.dll, libmysql.dll and libssl-1_1-x64.dll in the same folder as your .exe file (I'm guessing C:\Users\user\Documents\CP\build-DatabaseConnection-Desktop_Qt_6_3_1_MSVC2019_64bit-Release\release)
then open the subdirectory sqldrivers in the .zip file and copy the 2 files qsqlmysql.dll and qsqlmysqld.dll to the plugins folder of your newly installed Qt version 6.3.1, I'm guessing: C:\Qt\6.3.1\msvc2019_64\plugins\sqldriversIt worked. Thanks a lot @hskoglund . To anyone struggling with the same issue, the quoted steps are precisely what you should follow to solve your problem.
Thanks a million @hskoglund you are so kind.