Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Unable to connect to Mysql with release version



  • 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



  • @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.



  • @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


  • Lifetime Qt Champion

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



  • qsqlmysql.dll yes.



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



  • @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?



  • @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



  • @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,



  • @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
    


  • @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



  • @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....



  • @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



  • @JonB

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


  • Lifetime Qt Champion

    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.



  • 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



  • @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



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



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

    Thanks,
    --James



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


Log in to reply