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. QSqlDatabase: MYSQL driver not loaded
Forum Updated to NodeBB v4.3 + New Features

QSqlDatabase: MYSQL driver not loaded

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 7 Posters 1.4k Views 3 Watching
  • 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.
  • C Cervo2paille

    @SGaist Thanks for your answer.
    In fact there was an error in my "QMYSQL".

    I followed the doc : https://doc.qt.io/qt-6/sql-driver.html#qmysql
    But i got the same error : it didn't work, i got the same message.
    Someone has a good tutorial to connect to my MySQL (Xampp) ?
    I copied the lib and dll in my compilator, in my project... so way.

    Thanks

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #5

    @Cervo2paille said in QSqlDatabase: MYSQL driver not loaded:

    I followed the doc : https://doc.qt.io/qt-6/sql-driver.html#qmysql

    So, did you build and install the driver for MySQL? See the "How to Build the QMYSQL Plugin on Windows" chapter in the link you posted.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    C 1 Reply Last reply
    0
    • jsulmJ jsulm

      @Cervo2paille said in QSqlDatabase: MYSQL driver not loaded:

      I followed the doc : https://doc.qt.io/qt-6/sql-driver.html#qmysql

      So, did you build and install the driver for MySQL? See the "How to Build the QMYSQL Plugin on Windows" chapter in the link you posted.

      C Offline
      C Offline
      Cervo2paille
      wrote on last edited by
      #6

      @jsulm Hey,
      Sure i did. And after that I saw the note that notice it don't work and we must install "full MySQL Server (x64 only) or the MariaDB C Connector". I tried... and got the same error, again. :)
      Thanks

      jsulmJ 1 Reply Last reply
      0
      • C Cervo2paille

        @jsulm Hey,
        Sure i did. And after that I saw the note that notice it don't work and we must install "full MySQL Server (x64 only) or the MariaDB C Connector". I tried... and got the same error, again. :)
        Thanks

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @Cervo2paille said in QSqlDatabase: MYSQL driver not loaded:

        I tried... and got the same error, again. :)

        What exactly did you try?
        You need to install MariaDB C Connector before you build the plug-in. And then you pass the paths to the CMake call like shown in the documentation:

        qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib"
        

        So, did you do this?

        And one more question: when do you get this plug-in not loaded error: when you start your app from QtCreator or after deployment?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        C 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Cervo2paille said in QSqlDatabase: MYSQL driver not loaded:

          I tried... and got the same error, again. :)

          What exactly did you try?
          You need to install MariaDB C Connector before you build the plug-in. And then you pass the paths to the CMake call like shown in the documentation:

          qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib"
          

          So, did you do this?

          And one more question: when do you get this plug-in not loaded error: when you start your app from QtCreator or after deployment?

          C Offline
          C Offline
          Cervo2paille
          wrote on last edited by
          #8

          @jsulm You're right i got a problem on this line.
          I addapted to my system :

          qt-cmake -G Ninja D:\Qt\6.3.1\mingw_64\bin -DCMAKE_INSTALL_PREFIX="D:\Qt\6.3.1\mingw_64" -DMySQL_INCLUDE_DIR="D:\Program Files\MySQL\MySQL Server 8.0\include" -DMySQL_LIBRARY="D:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib"
          

          But i got a

          'qt-cmake' is not recognized as an internal command
          
          or external, an executable program or a batch file.
          

          I installed it , during the installation accepted to add to my Windows path the cmake... but it didn't worked.

          Thank you for your time

          jsulmJ 1 Reply Last reply
          0
          • C Cervo2paille

            @jsulm You're right i got a problem on this line.
            I addapted to my system :

            qt-cmake -G Ninja D:\Qt\6.3.1\mingw_64\bin -DCMAKE_INSTALL_PREFIX="D:\Qt\6.3.1\mingw_64" -DMySQL_INCLUDE_DIR="D:\Program Files\MySQL\MySQL Server 8.0\include" -DMySQL_LIBRARY="D:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib"
            

            But i got a

            'qt-cmake' is not recognized as an internal command
            
            or external, an executable program or a batch file.
            

            I installed it , during the installation accepted to add to my Windows path the cmake... but it didn't worked.

            Thank you for your time

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #9

            @Cervo2paille said in QSqlDatabase: MYSQL driver not loaded:

            I installed it , during the installation accepted to add to my Windows path the cmake

            qt_cmake should be part of your Qt installation, simply use full path to it.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Cervo2paille
              wrote on last edited by Cervo2paille
              #10

              Thanks
              But here we go again
              ha.png

              The 3 files are inside the project, where the documentation wants me to do :
              way.png

              MSVC runtime is installed.

              Maybe the problem come from the commands... i can see if they where well executed.

              Near to success... bot not yet.
              Thanks.

              SavithaS jsulmJ 2 Replies Last reply
              0
              • C Cervo2paille

                Thanks
                But here we go again
                ha.png

                The 3 files are inside the project, where the documentation wants me to do :
                way.png

                MSVC runtime is installed.

                Maybe the problem come from the commands... i can see if they where well executed.

                Near to success... bot not yet.
                Thanks.

                SavithaS Offline
                SavithaS Offline
                Savitha
                wrote on last edited by
                #11

                @Cervo2paille I think you must include the exe folder path in environmental "Path" variable

                1 Reply Last reply
                0
                • C Cervo2paille

                  Thanks
                  But here we go again
                  ha.png

                  The 3 files are inside the project, where the documentation wants me to do :
                  way.png

                  MSVC runtime is installed.

                  Maybe the problem come from the commands... i can see if they where well executed.

                  Near to success... bot not yet.
                  Thanks.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @Cervo2paille It looks like it is actually working? You just messed up with connections.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  C 1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Cervo2paille
                    wrote on last edited by Cervo2paille
                    #13
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @Cervo2paille It looks like it is actually working? You just messed up with connections.

                      C Offline
                      C Offline
                      Cervo2paille
                      wrote on last edited by Cervo2paille
                      #14

                      @jsulm Added Cmake Path and retry the commands. In fact, the commands seems to not be passed because here, they gave me an error :

                      C:\Users\flebourgeois\build-sqldrivers>qt-cmake -G Ninja D:\Users\flebourgeois\Documents\QT_Projets\blossom -DCMAKE_INSTALL_PREFIX="D:\Qt\6.3.1\mingw_64" -DMySQL_INCLUDE_DIR="D:\Program Files\MySQL\MySQL Server 8.0\include" -DMySQL_LIBRARY="D:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib"
                      CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
                      CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
                      -- Configuring incomplete, errors occurred!
                      

                      Tried to Install Ninja on my windows Ninja.

                      Config of my project under QT :
                      ninja.png

                      Maybe my -DCMAKE_INSTALL_PREFIX isn't ok ?
                      My CMAKE_MAKE_PROGRAM in QT show me a Ninja.exe, it's not ok ?
                      Thanks for your help :)

                      1 Reply Last reply
                      0
                      • hskoglundH Offline
                        hskoglundH Offline
                        hskoglund
                        wrote on last edited by
                        #15

                        Hi, you can also try without the -G Ninja stuff, e.g.

                        C:\Users\flebourgeois\build-sqldrivers>qt-cmake D:\Users\flebourgeois\Documents\Q...
                        C 1 Reply Last reply
                        0
                        • hskoglundH hskoglund

                          Hi, you can also try without the -G Ninja stuff, e.g.

                          C:\Users\flebourgeois\build-sqldrivers>qt-cmake D:\Users\flebourgeois\Documents\Q...
                          C Offline
                          C Offline
                          Cervo2paille
                          wrote on last edited by Cervo2paille
                          #16

                          @hskoglund Hey, thanks i successful to do the commands. But i got again and again the same error.
                          The installation :

                          D:\Users\fabdu\Documents\build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug>qt-cmake -G Ninja "D:\Users\fabdu\Documents\blossom" -DCMAKE_INSTALL_PREFIX="D:\Qt\6.3.1\mingw_64" -DMySQL_INCLUDE_DIR="D:\Program Files (x86)\MySQL\MySQL Server 5.5\include" -DMySQL_LIBRARY="D:\Program Files (x86)\MySQL\MySQL Server 5.5\lib\libmysql.lib"
                          -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
                          -- Configuring done
                          -- Generating done
                          CMake Warning:
                            Manually-specified variables were not used by the project:
                          
                              CMAKE_TOOLCHAIN_FILE
                              MySQL_INCLUDE_DIR
                              MySQL_LIBRARY
                          
                          
                          -- Build files have been written to: D:/Users/fabdu/Documents/build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug
                          
                          D:\Users\fabdu\Documents\build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug>cmake --build .
                          ninja: no work to do.
                          
                          D:\Users\fabdu\Documents\build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug>cmake --install .
                          -- Install configuration: "Debug"
                          -- Installing: D:/Qt/6.3.1/mingw_64/bin/blossom.exe
                          
                          D:\Users\fabdu\Documents\build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug>
                          

                          The famous error :

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

                          My Path :
                          code.png

                          I think i do a mistake about the starting of this line "qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers...".
                          What do you think about ? How to write it ?
                          If someone has an idea... thanks ! :)

                          piervalliP 1 Reply Last reply
                          0
                          • C Cervo2paille

                            @hskoglund Hey, thanks i successful to do the commands. But i got again and again the same error.
                            The installation :

                            D:\Users\fabdu\Documents\build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug>qt-cmake -G Ninja "D:\Users\fabdu\Documents\blossom" -DCMAKE_INSTALL_PREFIX="D:\Qt\6.3.1\mingw_64" -DMySQL_INCLUDE_DIR="D:\Program Files (x86)\MySQL\MySQL Server 5.5\include" -DMySQL_LIBRARY="D:\Program Files (x86)\MySQL\MySQL Server 5.5\lib\libmysql.lib"
                            -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
                            -- Configuring done
                            -- Generating done
                            CMake Warning:
                              Manually-specified variables were not used by the project:
                            
                                CMAKE_TOOLCHAIN_FILE
                                MySQL_INCLUDE_DIR
                                MySQL_LIBRARY
                            
                            
                            -- Build files have been written to: D:/Users/fabdu/Documents/build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug
                            
                            D:\Users\fabdu\Documents\build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug>cmake --build .
                            ninja: no work to do.
                            
                            D:\Users\fabdu\Documents\build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug>cmake --install .
                            -- Install configuration: "Debug"
                            -- Installing: D:/Qt/6.3.1/mingw_64/bin/blossom.exe
                            
                            D:\Users\fabdu\Documents\build-blossom-Desktop_Qt_6_3_1_MinGW_64_bit-Debug>
                            

                            The famous error :

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

                            My Path :
                            code.png

                            I think i do a mistake about the starting of this line "qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers...".
                            What do you think about ? How to write it ?
                            If someone has an idea... thanks ! :)

                            piervalliP Offline
                            piervalliP Offline
                            piervalli
                            wrote on last edited by
                            #17

                            @Cervo2paille I haved bat file for mariadb for WIndow if you want try.

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              Cervo2paille
                              wrote on last edited by
                              #18

                              thanks yes i would like to try :)

                              piervalliP 1 Reply Last reply
                              0
                              • C Cervo2paille

                                thanks yes i would like to try :)

                                piervalliP Offline
                                piervalliP Offline
                                piervalli
                                wrote on last edited by
                                #19

                                @Cervo2paille
                                That is my bat for maria db tested on 5.15.2

                                SET QTDIR="C:\Qt\5.15.2\Src"
                                SET MYSQL_INCDIR="C:\Program Files\MariaDB\MariaDB Connector C 64-bit\include"
                                SET MYSQL_LIBDIR="C:\Program Files\MariaDB\MariaDB Connector C 64-bit\lib"

                                SET PATH=%PATH%;C:\Qt\5.15.2\mingw81_64\bin;C:\Qt\Tools\mingw810_64\bin;

                                cd %QTDIR%\qtbase\src\plugins\sqldrivers
                                pause
                                qmake -- MYSQL_INCDIR=%MYSQL_INCDIR% MYSQL_LIBDIR=%MYSQL_LIBDIR%
                                pause
                                mingw32-make sub-mysql
                                pause
                                mingw32-make install
                                pause

                                1.Before build, clear the previous installation
                                2. copy libmariadb in exe directory

                                I hose it is useful.
                                The driver installed for Maria DB is "C Connector".

                                1 Reply Last reply
                                0

                                • Login

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