Unable to connect to local Mysql database in 64bit but able to do so under 32bit
-
wrote on 16 Jul 2018, 03:38 last edited by JohnFrom
Greetings.
I cannot connect with my Qt app to local mysql database in win7 64 bit, but in 32bit it is done perfectly fine.
Here is the code:
QSqlDatabase db;
db = QSqlDatabase::addDatabase("QMYSQL", "myserver");
db.setDatabaseName("myserver"); db.setHostName("localhost");// tried 127.0.0.1 too, same symptoms db.setUserName("******"); db.setPassword("******"); db.setPort(3306);
And I don't know if an error code cold be obtained because I haven't find any means to do that.
Any suggestions? What should I do to fix this?
-
Greetings.
I cannot connect with my Qt app to local mysql database in win7 64 bit, but in 32bit it is done perfectly fine.
Here is the code:
QSqlDatabase db;
db = QSqlDatabase::addDatabase("QMYSQL", "myserver");
db.setDatabaseName("myserver"); db.setHostName("localhost");// tried 127.0.0.1 too, same symptoms db.setUserName("******"); db.setPassword("******"); db.setPort(3306);
And I don't know if an error code cold be obtained because I haven't find any means to do that.
Any suggestions? What should I do to fix this?
hi @JohnFrom,
have you built the Qt MYSQL plugin for both architectures?
do you see any error in the console when your app is running?
regards
-
hi @JohnFrom,
have you built the Qt MYSQL plugin for both architectures?
do you see any error in the console when your app is running?
regards
wrote on 16 Jul 2018, 04:45 last edited by@aha_1980 said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
hi @JohnFrom,
have you built the Qt MYSQL plugin for both architectures?
Probably not - I'm maintaining someone else's code, and now I think about it, I have not factored in which target system I am building for, that is, I simply generated my app (you know, the .exe file) using the make project from the "build" menu.
I'm not exactly sure how to build that plugin at this point.
I'm a rookie on this, there probably are a lot of things I haven't thought about.
Oh, one more thing - the app can run pretty well on MY 64 bit win7 machine. The problem appears consistently on a newly installed win7 64bit, suggesting that there may be something I installed on my machine which enabled it to run properly.
Witht hat in mind, I tried uninstalling a lot of stuff to produce the same erroneous result, but couldn't. I tried install Qt on that freshly installed machine, but couldn't solve the problem. Quite frustrating.
do you see any error in the console when your app is running?
No not really, there isn't a console to begin with. It's not a console app and the only warning message box I got was "unable to connect to database", something coded in the program itself.
-
@aha_1980 said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
hi @JohnFrom,
have you built the Qt MYSQL plugin for both architectures?
Probably not - I'm maintaining someone else's code, and now I think about it, I have not factored in which target system I am building for, that is, I simply generated my app (you know, the .exe file) using the make project from the "build" menu.
I'm not exactly sure how to build that plugin at this point.
I'm a rookie on this, there probably are a lot of things I haven't thought about.
Oh, one more thing - the app can run pretty well on MY 64 bit win7 machine. The problem appears consistently on a newly installed win7 64bit, suggesting that there may be something I installed on my machine which enabled it to run properly.
Witht hat in mind, I tried uninstalling a lot of stuff to produce the same erroneous result, but couldn't. I tried install Qt on that freshly installed machine, but couldn't solve the problem. Quite frustrating.
do you see any error in the console when your app is running?
No not really, there isn't a console to begin with. It's not a console app and the only warning message box I got was "unable to connect to database", something coded in the program itself.
hi @JohnFrom,
- just google for 'qt mysql plugin'
- if you run you program from the IDE or command line in debug mode, you will see the warnings
-
hi @JohnFrom,
- just google for 'qt mysql plugin'
- if you run you program from the IDE or command line in debug mode, you will see the warnings
wrote on 16 Jul 2018, 06:03 last edited by@aha_1980 said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
hi @JohnFrom,
- just google for 'qt mysql plugin'
2 things:
-
there appears to be a ready-made project in the "plugin" folder of my Qt installation directory. But If I open it up with QT and try to build it, the "mySql.h" is missing, and I don't know which version I should download from the mysql site. If I use the latest source code from mysql, the compilation will result in more missing files because I'm using the wrong mysql.h.
-
It seems that I also need to build a 64bit app for win7 64. And to do that I need to manually build a 64 bit Qt in Visual studio 64??? That sounds rather unreasonable?
Could you be kind enough to help me a bit further? For starters where should I find the mysql plugin source code that is complete?
-
@aha_1980 said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
hi @JohnFrom,
- just google for 'qt mysql plugin'
2 things:
-
there appears to be a ready-made project in the "plugin" folder of my Qt installation directory. But If I open it up with QT and try to build it, the "mySql.h" is missing, and I don't know which version I should download from the mysql site. If I use the latest source code from mysql, the compilation will result in more missing files because I'm using the wrong mysql.h.
-
It seems that I also need to build a 64bit app for win7 64. And to do that I need to manually build a 64 bit Qt in Visual studio 64??? That sounds rather unreasonable?
Could you be kind enough to help me a bit further? For starters where should I find the mysql plugin source code that is complete?
Hi @JohnFrom,
Please follow the instructions here: http://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows You will need to install MySQL to have the header file available, I don't think you need the source code, just the header and lib files.
And you don't need to build Qt from source, there are several precompiled versions for the diverse compilers available.
Regards
-
Hi @JohnFrom,
Please follow the instructions here: http://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows You will need to install MySQL to have the header file available, I don't think you need the source code, just the header and lib files.
And you don't need to build Qt from source, there are several precompiled versions for the diverse compilers available.
Regards
wrote on 16 Jul 2018, 07:26 last edited by JohnFrom@aha_1980 said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
Hi @JohnFrom,
Please follow the instructions here: http://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows You will need to install MySQL to have the header file available, I don't think you need the source code, just the header and lib files.
And you don't need to build Qt from source, there are several precompiled versions for the diverse compilers available.
Regards
Hey thanks! I'll see what I can do!
Just one last thing - I SHOULD compile a 64bit version of my APP for a 64 bit system right? Or is it rather unnecessary?
-
@aha_1980 said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
Hi @JohnFrom,
Please follow the instructions here: http://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows You will need to install MySQL to have the header file available, I don't think you need the source code, just the header and lib files.
And you don't need to build Qt from source, there are several precompiled versions for the diverse compilers available.
Regards
Hey thanks! I'll see what I can do!
Just one last thing - I SHOULD compile a 64bit version of my APP for a 64 bit system right? Or is it rather unnecessary?
@JohnFrom said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
Just one last thing - I SHOULD compile a 64bit version of my APP for a 64 bit system right? Or is it rather unnecessary?
Windows x64 executes 32 bit apps without problem (tm). So no, it is not absolutely necessary.
Even on Linux it is possible to execute 32 bit programs on a 64 bit system - it's usually more work.
I can't tell for Mac.
Regards
-
Hi,
Don't bother trying to build your application for 32bit on macOS.
AFAIK, High Sierra is the last version of macOS where you'll be able to run 32bit application.
-
@JohnFrom said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
Just one last thing - I SHOULD compile a 64bit version of my APP for a 64 bit system right? Or is it rather unnecessary?
Windows x64 executes 32 bit apps without problem (tm). So no, it is not absolutely necessary.
Even on Linux it is possible to execute 32 bit programs on a 64 bit system - it's usually more work.
I can't tell for Mac.
Regards
wrote on 16 Jul 2018, 11:05 last edited by@aha_1980 said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
@JohnFrom said in Unable to connect to local Mysql database in 64bit but able to do so under 32bit:
Just one last thing - I SHOULD compile a 64bit version of my APP for a 64 bit system right? Or is it rather unnecessary?
Windows x64 executes 32 bit apps without problem (tm). So no, it is not absolutely necessary.
Even on Linux it is possible to execute 32 bit programs on a 64 bit system - it's usually more work.
I can't tell for Mac.
Regards
Thanks! I'm only building for win7 64bit though.
-
wrote on 17 Jul 2018, 09:18 last edited by
Lass and Gents:
I;ve figured it all out. Thanks to aha_1980, I decided that it's because of this:
Debugging starts
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Unable to open database
Debugging has finishedSo it's most likely that whatever "libmysql.dll" that came with the system or mysql installtion program isn't compatible with my app.
What I did is that I copy and replaced the "libmysql.dll" in my c:\windows with a correct version and viola! It's now up and kicking!
Thank you all!
-
Never put anything in
C:\Windows
. As you have seen the effect: application will use that version of the .dll rather than the one they were meant to use.Doing that, you might be breaking another application on your system.
You should always provide all the .dlls your application need in the proper place(s) of your installation tree.
1/12