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

MySQL driver not loaded in other computers.



  • Thanks all~

    After many attempts, I found that the required files were
    C:\Program Files\MySQL\MySQL Shell 8.0\bin\ -> libcrypto-1_1-x64.dll,libssl-1_1-x64.dll
    C:\Program Files\MySQL\MySQL Server 8.0\lib\ -> libmysql.dll
    into xxx.exe path


    IN QT 5.15
    I made a Qt application with mysql successfully.
    And then I want test it in other computers.
    I zip debug folder with required dlls and send it to my friends.
    Application succesfully starts and working.
    But, when accessing MySQL it says driver not loaded!
    Did I miss something???

    I try to

    The SQL database drivers are implemented as Qt plugins.
    All Qt plugins are in the "plugins" folder of your Qt installation. In that folder there is a subfolder called sqldrivers and this folder contains a file looking like "mysql.dll" which is the driver plugin for MySQL.
    To solve your issue, you must:
    1/ Create a "plugins" folder in your ZIP so that it will be next to your executable
    2/ Create a "sqldrivers" folder in that "plugins" folder and copy the "libmysql.dll" MySQL driver in that folder
    3/ In your main function, call @QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath())@
    
    Create a “sqldrivers” folder in the application's directory, then copy the xxxx.dll plugin to it is enough.
    No "plugins" directory is needed. No "addLibraryPath(...)" is needed
    
    I used the deployment tool windeployqt like windeployqt.exe one_path
    I copy libmysql.dll to binpath and can use it in my env
    I zip this folder and send to my friends, MySQL it says driver not loaded
    

    All Can't Solved


  • Lifetime Qt Champion

    @mengsen said in MySQL driver not loaded in other computers.:

    I zip debug folder with required dlls and send it to my friends.

    This is not enough.
    Please take a look at https://doc.qt.io/qt-5/windows-deployment.html
    There is explained what needs to be deployed and how. You can also use the Windows deployment tool (same link).



  • @jsulm said in MySQL driver not loaded in other computers.:

    There is explained what needs to be deployed and how. You can also use the Windows deployment tool (same link).

    1. I used the deployment tool windeployqt like windeployqt.exe one_path
    2. I copy libmysql.dll to binpath and can use it in my env
    3. I zip this folder and send to my friends, MySQL it says driver not loaded


  • @mengsen
    Then start by asking your users to set environment variable QT_DEBUG_PLUGINS to value 1 in a terminal. Then run your application from there. They will get a whole load of diagnostic output. Look at right near the end. Somewhere there should be information as to what the issue is for being unable to load the driver. You could compare this against the output you get when it's successful.


  • Lifetime Qt Champion

    @mengsen said in MySQL driver not loaded in other computers.:

    I copy libmysql.dll to binpath and can use it in my env

    Plug-ins should be inside plugins sub-folder as described in the link I posted before.
    In your environment it is working because the plug-ins are also available from your Qt installation. You can test locally on a vanilla Windows before sending to your customers (you could use a virtual machine with Windows).



  • @JonB Can I set it on Windows



  • @mengsen
    Of course!

    1. Open a Command Prompt.
    2. Type: set QT_DEBUG_PLUGINS=1, then <Enter> key.
    3. Run the executable (presumably by typing its full path).
    4. Look at what you get back in the Command Prompt.

    Try it first on your system where it works. Then try it where it does not. You are usually interested in the end of the diagnostic output, where it indicates why it could not load MySQL driver.

    EDIT Ohhh, I have a bad feeling that under Windows someone said the diagnostic output does not go to the terminal where you run from, like it does under Linux, instead it goes somewhere for Windows logging instead :(

    Yep, see https://www.qtcentre.org/threads/34927-QT_DEBUG__PLUGINS-Windows-7-where-does-it-log-information
    One post said "Then I use sysinternals debugview free utility to monitor the output at run-time."
    See post on this forum https://forum.qt.io/topic/41943/platform-plugin-windows/8

    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


Log in to reply