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. win10 fails to connect to mysql but the same binary+dll's work on win7
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 545 Views
  • 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.
  • Seb TurS Offline
    Seb TurS Offline
    Seb Tur
    wrote on last edited by
    #1

    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 db.open() 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.

    1 Reply Last reply
    0
    • Seb TurS Offline
      Seb TurS Offline
      Seb Tur
      wrote on last edited by Seb Tur
      #2

      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
      db_host
      db_name

      for example
      192.168.0.9
      my_db

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

      db.setHostName(sql_host);
      db.setDatabaseName(db_name);
      
      db.setUserName("user");
      db.setPassword(as+as);
      bool ok = db.open();
      

      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.

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved