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 error in Qt
Forum Updated to NodeBB v4.3 + New Features

MYSQL error in Qt

Scheduled Pinned Locked Moved Solved General and Desktop
23 Posts 7 Posters 3.2k Views 1 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.
  • T Offline
    T Offline
    tmapp
    wrote on last edited by
    #3

    there are 2 cases :
    1. the driver does not exists in plugin/sqldrivers
    2. an other error coming from you project.
    Solutions:
    1. you need to make the driver by your self, as mentioned in the topic: here
    2. active the QT_DEBUG_PLUGINS and past the errors here, that way you can help other's understand the issue to help you, as @JonB said.
    Good luck.

    1 Reply Last reply
    1
    • T Offline
      T Offline
      tmapp
      wrote on last edited by tmapp
      #4

      Hi ,
      I tested the following solution and worked for me
      Here is your solution :

      • start by commenting QMAKE_USE += mysql by a #
        in PATH_TO_QT_Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro

      AND : follow this instructions link here

      1. don't forget to copy libmysql.dll to mingw32 bin path and to your project path
        Congrats!
      • Just remember: if you want 32bit use the 32bit versions , but 64 use the 64 even mingw use 64 .... respect the version to have full working driver.
      • other remark: don't use path's where spaces exists exmpl : C:\Program Files\Mysql....
        this will create error in mingw-make ( Files not recognized ..... ) but use strict path's like : C:\Mysql...... etc
        Good Luck.
      A 1 Reply Last reply
      0
      • T tmapp

        Hi ,
        I tested the following solution and worked for me
        Here is your solution :

        • start by commenting QMAKE_USE += mysql by a #
          in PATH_TO_QT_Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro

        AND : follow this instructions link here

        1. don't forget to copy libmysql.dll to mingw32 bin path and to your project path
          Congrats!
        • Just remember: if you want 32bit use the 32bit versions , but 64 use the 64 even mingw use 64 .... respect the version to have full working driver.
        • other remark: don't use path's where spaces exists exmpl : C:\Program Files\Mysql....
          this will create error in mingw-make ( Files not recognized ..... ) but use strict path's like : C:\Mysql...... etc
          Good Luck.
        A Offline
        A Offline
        Alfie Anil
        wrote on last edited by
        #5

        @tmapp Hi, thanks for the help. I'm new to qt, and I'm not sure what you meant (what you want me to do exactly) by the first bullet point, could you explain please. sorry for the inconvenience.

        T T 2 Replies Last reply
        0
        • A Alfie Anil

          @tmapp Hi, thanks for the help. I'm new to qt, and I'm not sure what you meant (what you want me to do exactly) by the first bullet point, could you explain please. sorry for the inconvenience.

          T Offline
          T Offline
          thecodemonkey
          wrote on last edited by thecodemonkey
          #6

          @Alfie-Anil you can use my precompiled QMYSQL driver if you like. Get it from https://github.com/thecodemonkey86/qt_mysql_driver/releases according to your Qt version and compiler and put qsqlmysql.dll (if release build) or qsqlmysqld.dll (if debug build) in your application subdirectory "sqldrivers", plus in application directory (or somewhere else referenced by your PATH variable) libmysql.dll (plus, if required, the DLLs from OpenSSL - libssl-1_1-x64.dll and libcrypto-1_1-x64.dll)

          Edit: added screen shot how it looks like in Windows Explorer
          75b76ebb-8e73-4ea2-8651-aa387c415142-grafik.png

          40c65099-609f-4ad5-9d42-aa343eaf795b-grafik.png

          1 Reply Last reply
          0
          • A Alfie Anil

            @tmapp Hi, thanks for the help. I'm new to qt, and I'm not sure what you meant (what you want me to do exactly) by the first bullet point, could you explain please. sorry for the inconvenience.

            T Offline
            T Offline
            tmapp
            wrote on last edited by
            #7

            @Alfie-Anil edit the file : PATH_TO_QT_Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro in a text editor you prefer, you'll find a line QMAKE_USE +=mysql
            add before it # , it'll be like this : #QMAKE_USE += mysql
            save the file and procced with the next steps.

            Christian EhrlicherC 1 Reply Last reply
            0
            • T tmapp

              @Alfie-Anil edit the file : PATH_TO_QT_Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro in a text editor you prefer, you'll find a line QMAKE_USE +=mysql
              add before it # , it'll be like this : #QMAKE_USE += mysql
              save the file and procced with the next steps.

              Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @tmapp There is no reason to modify any qt source or config file when you want to compile a sql plugin...

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              T 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @tmapp There is no reason to modify any qt source or config file when you want to compile a sql plugin...

                T Offline
                T Offline
                tmapp
                wrote on last edited by
                #9

                @Christian-Ehrlicher that's how it worked with me on postgresql and mysql ; otherwise it'll display an error : mysql model is not defined , and same for postgresql ( speaking about QT 5.11 )

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Alfie Anil
                  wrote on last edited by
                  #10

                  @tmapp Hi, I've tried that but nothing seems to be working. I'm still getting the same error

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @Alfie-Anil said in MYSQL error in Qt:

                    Hi, I've tried that but nothing seems to be working. I'm still getting the same error

                    Not very helpful answer...

                    Please start with a clean qt source tree, follow the documentation and post the output. Also notice the comments to config.log in the documentation

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    1
                    • A Offline
                      A Offline
                      Alfie Anil
                      wrote on last edited by
                      #12

                      Hello everyone, I was following through the documentation as suggested by @Christian-Ehrlicher . The first command I added was 'qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"

                      But the outcome was different to that which was in the documentation. This was what I got:

                      QMake has two modes, one mode for generating project files based on
                      some heuristics, and the other for generating makefiles. Normally you
                      shouldn't need to specify a mode, as makefile generation is the default
                      mode for qmake, but you may use this to test qmake on an existing project
                      
                      Mode:
                        -project       Put qmake into project file generation mode
                                       In this mode qmake interprets [files] as files to
                                       be added to the .pro file. By default, all files with
                                       known source extensions are added.
                                       Note: The created .pro file probably will
                                       need to be edited. For example add the QT variable to
                                       specify what modules are required.
                        -makefile      Put qmake into makefile generation mode (default)
                                       In this mode qmake interprets files as project files to
                                       be processed, if skipped qmake will try to find a project
                                       file in your current working directory
                      
                      Warnings Options:
                        -Wnone         Turn off all warnings; specific ones may be re-enabled by
                                       later -W options
                        -Wall          Turn on all warnings
                        -Wparser       Turn on parser warnings
                        -Wlogic        Turn on logic warnings (on by default)
                        -Wdeprecated   Turn on deprecation warnings (on by default)
                      
                      Options:
                         * You can place any variable assignment in options and it will be *
                         * processed as if it was in [files]. These assignments will be    *
                         * processed before [files] by default.                            *
                        -o file        Write output to file
                        -d             Increase debug level
                        -t templ       Overrides TEMPLATE as templ
                        -tp prefix     Overrides TEMPLATE so that prefix is prefixed into the value
                        -help          This help
                        -v             Version information
                        -early         All subsequent variable assignments will be
                                       parsed right before default_pre.prf
                        -before        All subsequent variable assignments will be
                                       parsed right before [files] (the default)
                        -after         All subsequent variable assignments will be
                                       parsed after [files]
                        -late          All subsequent variable assignments will be
                                       parsed right after default_post.prf
                        -norecursive   Don't do a recursive search
                        -recursive     Do a recursive search
                        -set <prop> <value> Set persistent property
                        -unset <prop>  Unset persistent property
                        -query <prop>  Query persistent property. Show all if <prop> is empty.
                        -qtconf file   Use file instead of looking for qt.conf
                        -cache file    Use file as cache           [makefile mode only]
                        -spec spec     Use spec as QMAKESPEC       [makefile mode only]
                        -nocache       Don't use a cache file      [makefile mode only]
                        -nodepend      Don't generate dependencies [makefile mode only]
                        -nomoc         Don't generate moc targets  [makefile mode only]
                        -nopwd         Don't look for files in pwd [project mode only]
                      

                      Any ideas?
                      Thanks

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        Hi,

                        You are likely not in the right folder, likely in your Qt installation rather than sources.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        1
                        • A Offline
                          A Offline
                          Alfie Anil
                          wrote on last edited by
                          #14

                          So I opened the terminal from the qt5.13.2 mingw32. Is that where i open the terminal from or is it another directory?

                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Online
                            Christian EhrlicherC Online
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            @Alfie-Anil said in MYSQL error in Qt:

                            Is that where i open the terminal from or is it another directory?

                            That's correct. But then you have to go to the correct source dir as you can see in the documentation: <srcdir>\qtbase\src\plugins\sqldrivers
                            Is it really that hard to follow the instructions?

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            1 Reply Last reply
                            2
                            • A Offline
                              A Offline
                              Alfie Anil
                              wrote on last edited by
                              #16

                              I've tried everything said but still comes up with the exact error.

                              Christian EhrlicherC 1 Reply Last reply
                              0
                              • A Alfie Anil

                                I've tried everything said but still comes up with the exact error.

                                Christian EhrlicherC Online
                                Christian EhrlicherC Online
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #17

                                @Alfie-Anil said in MYSQL error in Qt:

                                I've tried everything said but still comes up with the exact error.

                                Did you really call the correct qmake in the correct directory? I would guess no.

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  Alfie Anil
                                  wrote on last edited by
                                  #18

                                  @Christian-Ehrlicher Yes I did. As stated in the documentation I cd to the correct directory and then followed the commands as given.

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • A Alfie Anil

                                    @Christian-Ehrlicher Yes I did. As stated in the documentation I cd to the correct directory and then followed the commands as given.

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

                                    @Alfie-Anil The question was rather: did you call correct qmake?
                                    To make sure you call correct qmake use absolute path (instead of simply calling qmake).

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

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      Alfie Anil
                                      wrote on last edited by
                                      #20

                                      So do you mean 'C:<NecessaryDirectory>? Yes

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • A Alfie Anil

                                        So do you mean 'C:<NecessaryDirectory>? Yes

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

                                        @Alfie-Anil Yes, absolute path like c:\Qt\5.12.0\mingw73_64\bin\qmake.exe

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

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          Alfie Anil
                                          wrote on last edited by
                                          #22

                                          Yes That's what I did

                                          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