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. Unable to connect to Mysql with release version
Forum Updated to NodeBB v4.3 + New Features

Unable to connect to Mysql with release version

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 6 Posters 1.4k 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.
  • J Offline
    J Offline
    JSher
    wrote on last edited by
    #1

    Hello,

    I have built a project and am trying to build a release version to deploy. The application works fine in Qt Creator and I even ported it to Visual Studio and tried and I get the same result.

    Steps Ive taken in both Qt Creater with Min_GW and VS with msvc_2017:
    --Create the application working in both
    --build the release version
    --copy the exe to a fresh directory
    --run windepolyqt
    --copy missing .dlls requested by ext
    --copy libmysql.lib and.dll

    It will not connect to the mysql database no matter what I try. On mingw I even coppied the WHOLE mingw directory in an attempt to see what was missing, still will not connect.

    I am at a loss, any ideas?

    Thanks

    JonBJ 1 Reply Last reply
    0
    • J JSher

      Hello,

      I have built a project and am trying to build a release version to deploy. The application works fine in Qt Creator and I even ported it to Visual Studio and tried and I get the same result.

      Steps Ive taken in both Qt Creater with Min_GW and VS with msvc_2017:
      --Create the application working in both
      --build the release version
      --copy the exe to a fresh directory
      --run windepolyqt
      --copy missing .dlls requested by ext
      --copy libmysql.lib and.dll

      It will not connect to the mysql database no matter what I try. On mingw I even coppied the WHOLE mingw directory in an attempt to see what was missing, still will not connect.

      I am at a loss, any ideas?

      Thanks

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @JSher
      Do you not get any error message anywhere? Do you get anything from QSqlDatabase::lastError() when you try to connect/open? Unless I am mistaken, isn't the QMYSQL stuff a Qt plugin, in which case run with environment variable QT_DEBUG_PLUGINS=1.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JSher
        wrote on last edited by
        #3

        @JonB said in Unable to connect to Mysql with release version:

        QSqlDatabase::lastError()

        The error is 'Driver not loaded'.

        I have tried putting the driver everywhere and do not understand why it is not picking it up. Is there something I can do to trace why it is not loading or what it is looking for?

        Thanks

        JonBJ 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          So does windeployqt copy the qmysql.dll into the sqldrivers subdir?

          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
          • J Offline
            J Offline
            JSher
            wrote on last edited by
            #5

            qsqlmysql.dll yes.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Bonnie
              wrote on last edited by Bonnie
              #6

              Where does your libmysql.dll come from?
              By the way, libmysql.lib is not needed when deploying.

              1 Reply Last reply
              0
              • J JSher

                @JonB said in Unable to connect to Mysql with release version:

                QSqlDatabase::lastError()

                The error is 'Driver not loaded'.

                I have tried putting the driver everywhere and do not understand why it is not picking it up. Is there something I can do to trace why it is not loading or what it is looking for?

                Thanks

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @JSher said in Unable to connect to Mysql with release version:

                I have tried putting the driver everywhere and do not understand why it is not picking it up. Is there something I can do to trace why it is not loading or what it is looking for?

                That's why I said

                in which case run with environment variable QT_DEBUG_PLUGINS=1

                which I thought is the first port-of-call in this situation?

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  JSher
                  wrote on last edited by
                  #8

                  @JonB said in Unable to connect to Mysql with release version:

                  QT_DEBUG_PLUGINS=1

                  Sorry I misunderstood. Thought that was just to diagnos what was missing.

                  Bonnie, I downloaded it from mysql, its the same one in the minGW directory that works under Creator.

                  @JonB this worked in diagnosing my issue! Thanks.

                  So to explain for more newbie people like me:
                  You put QT_DEBUG_PLUGINS in the project tab on the left and add it to the environment variables and sent the value to 1.

                  Then I launched in debug and everything the program was doing in regards to plugins was verbose in the output.

                  From this I descerned that it was looking for the qsqlite.dll in the plugins/sqldrivers of the minGW.

                  The windeploy tool put it just in an sqldrivers folder so I created a plugins folder and moved it there and voila, it worked!!

                  Thanks:)

                  Thanks

                  M 1 Reply Last reply
                  2
                  • J Offline
                    J Offline
                    JSher
                    wrote on last edited by
                    #9

                    @JonB
                    So I deployed to another machine and I get the same error.

                    To test on my machine I renamed the QT directory so it was not picking up anything from it and it worked fine. Any idea how to diagnose when its happening on another machine. Other machine is windows 10 as well.

                    Thanks,

                    JonBJ 1 Reply Last reply
                    0
                    • J JSher

                      @JonB
                      So I deployed to another machine and I get the same error.

                      To test on my machine I renamed the QT directory so it was not picking up anything from it and it worked fine. Any idea how to diagnose when its happening on another machine. Other machine is windows 10 as well.

                      Thanks,

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #10

                      @JSher
                      You have to do the same as before. You don't have to have Qt Creator. E.g. hopefully you can run your app from a Command Prompt:

                      set QT_DEBUG_PLUGINS=1
                      your-app-exe
                      
                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        JSher
                        wrote on last edited by
                        #11

                        @JonB said in Unable to connect to Mysql with release version:

                        set QT_DEBUG_PLUGINS=1
                        your-app-exe

                        I opened a command prompt and set it and then ran it but nothing appeared in the command promp and the program opened. Am I missing something?

                        Thanks,
                        --James

                        JonBJ 1 Reply Last reply
                        0
                        • J JSher

                          @JonB said in Unable to connect to Mysql with release version:

                          set QT_DEBUG_PLUGINS=1
                          your-app-exe

                          I opened a command prompt and set it and then ran it but nothing appeared in the command promp and the program opened. Am I missing something?

                          Thanks,
                          --James

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #12

                          @JSher
                          Bearing in mind I have no expereince of this.... I might bet that this post from 2014 for Windows still applies?
                          https://forum.qt.io/topic/41943/platform-plugin-windows/8

                          hskoglund 31 May 2014, 06:03

                          Hi, just an update on why QT_DEBUG_PLUGINS=1 doesn't work as expected when you launch a Qt app from the command line (as it does on Linux and Macs): I found that for Windows MSVC and MinGW compilers, Qt routes the texts to OutputDebugString(), that's why the CMD window shows no output.

                          Instead, to see the output, download "Sysinternal's DbgView":http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx

                          ...? :)

                          Which you'd have to do since it solved you before on your machine. BTW, you did try making the same change on the new machine as you found you had to do on the other machine, didn't you? It wouldn't be surprising if it's the same issue with the same requirement....

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            JSher
                            wrote on last edited by
                            #13

                            @JonB Sorry can only reply every 10 minutes":)

                            Yes I kept all the same files in the same directory. I am about to try on another machine. Dunno why that would make a difference but you never know.

                            Thanks
                            --James

                            1 Reply Last reply
                            0
                            • J Offline
                              J Offline
                              JSher
                              wrote on last edited by
                              #14

                              @JonB

                              So the strange thing is, it works on 2 other computers....ugg

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

                                Hi,

                                One thing you can do is run Dependency Walker on these various machines to check is there's a difference with the dependencies of the MySQL dlls.

                                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
                                0
                                • J Offline
                                  J Offline
                                  JSher
                                  wrote on last edited by
                                  #16

                                  I found the issue:

                                  It says it cannot find qsqlmysqld.dll. Any reason why it could not load this library? It is an older computer but running windows 10. It finds all the rest and shows the path to where it and the rest it does load in the Module debug.

                                  Thanks,
                                  --James

                                  JonBJ 1 Reply Last reply
                                  0
                                  • J JSher

                                    I found the issue:

                                    It says it cannot find qsqlmysqld.dll. Any reason why it could not load this library? It is an older computer but running windows 10. It finds all the rest and shows the path to where it and the rest it does load in the Module debug.

                                    Thanks,
                                    --James

                                    JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by
                                    #17

                                    @JSher said in Unable to connect to Mysql with release version:

                                    qsqlmysqld.dll

                                    The d at the end sounds like this is compiled for debug? You said you did Release build, so I wonder why this is needed at target machine?

                                    Meanwhile, read https://bugreports.qt.io/browse/QTBUG-78241

                                    1 Reply Last reply
                                    0
                                    • J Offline
                                      J Offline
                                      JSher
                                      wrote on last edited by
                                      #18

                                      Oh I threw a debug version on it to see the module load sequence.

                                      1 Reply Last reply
                                      0
                                      • J Offline
                                        J Offline
                                        JSher
                                        wrote on last edited by
                                        #19

                                        I am going to create a new question as this one is technically solved and a new one has popped up..

                                        Thanks,
                                        --James

                                        1 Reply Last reply
                                        0
                                        • J JSher

                                          @JonB said in Unable to connect to Mysql with release version:

                                          QT_DEBUG_PLUGINS=1

                                          Sorry I misunderstood. Thought that was just to diagnos what was missing.

                                          Bonnie, I downloaded it from mysql, its the same one in the minGW directory that works under Creator.

                                          @JonB this worked in diagnosing my issue! Thanks.

                                          So to explain for more newbie people like me:
                                          You put QT_DEBUG_PLUGINS in the project tab on the left and add it to the environment variables and sent the value to 1.

                                          Then I launched in debug and everything the program was doing in regards to plugins was verbose in the output.

                                          From this I descerned that it was looking for the qsqlite.dll in the plugins/sqldrivers of the minGW.

                                          The windeploy tool put it just in an sqldrivers folder so I created a plugins folder and moved it there and voila, it worked!!

                                          Thanks:)

                                          Thanks

                                          M Offline
                                          M Offline
                                          Mathieu T.
                                          wrote on last edited by
                                          #20

                                          @JSher it worked for me as well to put the sqldrivers folder in a plugin folder! thanks you very much !!! :D

                                          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