Solved 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 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.
-
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_namefor example
192.168.0.9
my_dband 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.