Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MySql open doesn't work.
Forum Updated to NodeBB v4.3 + New Features

MySql open doesn't work.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 299 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dennis.kim
    wrote on 11 Apr 2022, 02:56 last edited by
    #1

    Hi,

    I've seen several docs for mysql in action. But I haven't found a solution on the 3rd day.

    Test enviorment>

    • window 10
    • Qt 5.13.2
    • mingw73_64
    • using mysql-8.0.16 dll

    First of all, in code, when database.open is executed, false is returned.

    .pro>

    QT       += sql
    

    Main.cpp>

    #include <QtSql>
    #include <QSqlDatabase>
    
    ..........................................................................................
        qDebug() << "driverlist " << QSqlDatabase::drivers();
    
        QSqlDatabase database;
        database = QSqlDatabase::addDatabase("QMYSQL");
        qDebug() << "db connection " << database.open();
    -------------------------------------------
    

    result as blow>

    driverlist  ("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    db connection  false
    

    I followed the doc below for mysql connection.
    https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

    • I downloaded the mysql zip file. then unzipped.
      e76a9ce2-97b0-4f80-8cac-d8a6d40f2ff8-image.png

    • Some of the tasks listed in the official documentation were executed as follows.

    C:\Qt\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -version
    QMake version 3.1
    Using Qt version 5.13.2 in C:/Qt/5.13.2/mingw73_64/lib
    
    C:\Qt\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:\mysql-8.0.16-winx64/include" MYSQL_LIBDIR="C:\mysql-8.0.16-winx64/lib"
    Info: creating stash file **C:\Qt\5.13.2\Src\qtbase\src\plugins\sqldrivers\.qmake.stash
    
    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 Drivers:
      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, you must run 'mingw32-make install'.
    Qt will be installed into 'C:\Qt\5.13.2\mingw73_64'.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    
    • driver install
      816d4794-94b8-4384-8a87-9bdb3e6820cc-image.png

    • I copied the libmysql.dll file to the two places below.
      C:\Qt\5.13.2\mingw73_64\bin
      Where the build exe of the test code is located.

    Is there a way to find the cause of the problem or is there any work that is not done yet?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dennis.kim
      wrote on 11 Apr 2022, 04:58 last edited by
      #2

      Finally solved it.

      In conclusion, proceed as follows.
      Please refer to those who wish.

      First, proceed with the basic tasks in the basic document.

      Please refer to the site below or what I did in the question I wrote.
      https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

      And download the appropriate driver from the site below.
      I use qt15.3.2, so I downloaded the 15.3.2 driver.
      https://github.com/thecodemonkey86/qt_mysql_driver/releases

      I pasted the files into the two folders below each.
      C:\Qt\5.13.2\mingw73_64\bin
      C:\Qt\5.13.2\mingw73_64\plugins\sqldrivers

      J 1 Reply Last reply 11 Apr 2022, 08:35
      0
      • D dennis.kim
        11 Apr 2022, 04:58

        Finally solved it.

        In conclusion, proceed as follows.
        Please refer to those who wish.

        First, proceed with the basic tasks in the basic document.

        Please refer to the site below or what I did in the question I wrote.
        https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

        And download the appropriate driver from the site below.
        I use qt15.3.2, so I downloaded the 15.3.2 driver.
        https://github.com/thecodemonkey86/qt_mysql_driver/releases

        I pasted the files into the two folders below each.
        C:\Qt\5.13.2\mingw73_64\bin
        C:\Qt\5.13.2\mingw73_64\plugins\sqldrivers

        J Offline
        J Offline
        JonB
        wrote on 11 Apr 2022, 08:35 last edited by
        #3

        @dennis-kim
        Just so I understand (I don't use Windows for Qt): why did you need to build a MySQL driver at all from sources, rather than just downloading an already-built version?

        1 Reply Last reply
        0

        1/3

        11 Apr 2022, 02:56

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved