qt 5.8 sql connection error:QMYSQL driver not loaded on windows 10

后端 未结 5 940
别跟我提以往
别跟我提以往 2020-12-06 19:24

When i tried to connect to mysql, there is a error:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODB         


        
相关标签:
5条回答
  • 2020-12-06 19:35

    I had the same problem. I could solved it by following Benjamin T advise. - Windows 10 - python 3.7 - PyQt5 - I copied the libmysql.dll file from the python 3.7/lib/site-packages folder to the Python 3.7 executable folder and everything started working just fine!

    0 讨论(0)
  • 2020-12-06 19:42
    1. You must rebuild mysql driver.
    2. Follow this guide

      Note: you need 3 things:

      a. qt-opensource-xxx-mingw492-xxx.exe for Qt Creator and Qt command Prompt.

      b.qt-everywhere-opensource-src-xxx.zip for Qt source code, needed for mysql.pro file. c.mysql-connector-c-6.1.10-win32.zip needed for lib and include folder.

    0 讨论(0)
  • 2020-12-06 19:45

    There are 64 bit and 32 bit versions of libmysql.dll. rebuilding the Qt Driver is NOT a must.

    With the prebuilt version of Qt5.9.1, you still need to use the 32 bit version, it worked even with the 64 version of MySQL installation. without any rebuild of QT plugins or components. Download 32 bit MySQL connector here

    This was already answered here: medasumanth answer

    0 讨论(0)
  • 2020-12-06 19:47

    If anyone is stupid as i am so that's for you: What basically you should do is

    1. go to https://downloads.mysql.com/archives/c-c/ and download specifically C !!!!!! MysqlConnector;
    2. place "libmysql.dll" and "libmysql.lib" ("mysql-connector-c-6.1.11-winx64.zip\mysql-connector-c-6.1.11-winx64\lib") into "c:\path_to_qt\qt_version\your_compiler\bin\" for me it looked like "c:\Qt\5.12.1\mingw73_64\bin\";
    3. reload creator and voila your mysql driver is perfectly loaded;

    So basically for those who want to understand what happened here:

    That "qsqlmysql" plugin is basically a qt interface that uses mysql-C connector methods. But unfortunately this connector does not distributed with Qt, so you should provide it by yourself.

    If you want to distribute your software you should copy "libmysql.dll" into the folder with your ".exe" file.

    I hope this will help someone save some time (3hours for me :) ).

    0 讨论(0)
  • 2020-12-06 19:54

    This error generally means that Qt MySQL plugin is fine (as it is listed in available drivers), but you are a missing the MySQL dll (thus preventing the driver to load).

    The way to fix it is to place libmysql.dll somewhere in your PATH, e.g. adding the MySQL installation folder to PATH, or copy libmysql.dll in the same folder you have your exe in.

    0 讨论(0)
提交回复
热议问题