Qt 4.8.5 + MySQL + Windows
-
Hi and welcome to devnet,
First thing to do install reinstall MySQL in a path without space or use the old 8.3 format to give the library path then try again.
You can also find numerous posts about this subject that might help you on this forum
Hope it helps
-
Thanks for the reply,
I did what you proposed (removed & reinstalled MySQL with 8.3 format name) but I get the same error.
I look for a post to help me but I found nothing helpful. May be it's my lack of knowledge that prevent me to found something.
Any suggestion from this...
If anyone understand the meaning of the previous error message, that will be really appreciated.
-
Hi, I suggest to follow this tutorial "Qt5 MYSQL Win7":http://seppemagiels.com/blog/create-mysql-driver-qt5-windows
-
I didn't suggest to install it using 8.3 names, just in a path without spaces. If you wanted to keep your original installation, you would have need to use the 8.3 notations.
Where do you have your MySQL installed now ?
-
I follow the steps in this tutorial ("Create MySQL driver for Qt on Windows":http://seppemagiels.com/blog/create-mysql-driver-qt-windows) and I adapt some of it for my situation :
-
Qt 4.8.5
-
Microsoft Visual Studio 2010
-
I also installed MySQL 5.5 32bits
-
then I followed this steps : run the following commands from the Qt Command Prompt
-
set mysql=C:\PROGRA~2\MySQL\MYSQLS~1.5
-
cd C:\Qt\4.8.5\src\plugins\sqldrivers\mysql
-
qmake "INCLUDEPATH+=%mysql%\include" "LIBS+=%mysql%\lib\libmysql.lib" -o Makefile mysql.pro
-
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"
-
qmake "INCLUDEPATH+=%mysql%\include" "LIBS+=%mysql%\lib\libmysql.lib" -o Makefile mysql.pro "CONFIG+=release"
-
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"
At this point, everything seem to go well. Thanks to you both.
From now I copy the following to C:\Qt\4.8.5\plugins\sqldrivers
-
qsqlmysql4.dll + qsqlmysql4.lib (from C:\Qt\4.8.5\src\plugins\sqldrivers\mysql\release)
-
qsqlmysqld4.dll + qsqlmysqld4.lib (from C:\Qt\4.8.5\src\plugins\sqldrivers\mysql\debug)
Also copying
C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib\libmysql.dll
to
C:\Qt\4.8.5\bin
From this, I was sure it should work!
But I got a strange behavior, when I run this command :
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", "my_sql_db");
I got this output :
...
'Database01.exe' : Chargé 'C:\Qt\4.8.5\plugins\sqldrivers\qsqlmysqld4.dll', Les symboles ont été chargés.
'Database01.exe' : Déchargé 'C:\Qt\4.8.5\plugins\sqldrivers\qsqlmysqld4.dll'
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
...
I'm sorry for the french part again (Chargé mean loaded) and (Déchargé mean unloaded).
Now, do somebody know why the driver seem to load and unload immediately after?
Thanks again!
-
-
Did you check what lastError() returns ?
-
I didn't check, thanks.
The return is
driverError = "Driver not loaded"
databaseError = "Driver not loaded"
errorType = ConnectionError
errorNumber = -1This is interesting, but it doesn't explain why the driver seems to load and right after it is unloaded.
Thanks for your help...
-
copy the libmysql.dll to the application directory.
Erni35
-
Thanks for this input.
I copied this DLL everywhere just to be sure (qt/bin, windows/system32, in the application directory, ...)
And I obtain the same result... :-(
-
Did you copy libmysqld.dll for debug build, too?
-
You found something here. I did not copy the debug DLL. But I can't find it on the MySQL installation.
I found the release version on the MySQL/lib folder. And if I compile and run in release, I still got the same problem.