Important: Please read the Qt Code of Conduct -

win10 fails to connect to mysql but the same binary+dll's work on win7

  • Hi
    I have created binaries using qt 5.9.8 with mingw and mysql support. All works fine on test win7 dev and win7 test machines (blank system)
    I have the exe and the whole set of required dll on a pendrive to test it on different machines.
    All works on win 7 , it even work in windows emulation called WINE in Linux but it fails in win10 x32 and x64
    What is strange is that returns true but when I execute a query I get an error "MySQL server has gone away"

    I have disabled any firewall on win10 and on the the same win10 machines i'm ableto login to this mysql server from mysql cmd line.

    any hints where to look for?

    I tried building mysql plugin with different libmysql.dll versions - from mysql server and from mysql connector. the same result.

  • Found a bug - using QT_DEBUG_PLUGINS helped here.

    for some reason qt on win10 reads text files in a different way or sql treads db.setHostName parameter in a different way

    so when I have a txt file .myconfig with 2 lines

    for example

    and code
    File file(QDir::homePath()+"/.myconfig");
    if (! | QIODevice::Text))
    qDebug()<<" konf not open";
    QString sql_host;
    QTextStream in(&file);
    sql_host = in.readLine();
    db_name = in.readLine();

    bool ok =;

    it was giving ok=true but failing on queries

    fix was to use:
    sql_host = in.readLine().trimmed();
    intead of
    sql_host = in.readLine();

    so readLine() was adding space at the end in win10 (.myconfig file edited in notepad)

    hope this helpes somebody else.

Log in to reply