PDA

View Full Version : QMYSQL database driver installation files



babygal
26th July 2010, 03:44
I want to use QMYSQL.
What are the driver installation files I need to install to work with my Qt4.6.2
and where can i get it?
Which version of QMYSQL I need to use ?
What are the procedures?

saa7_go
26th July 2010, 03:59
Read this guide (http://www.qtcentre.org/wiki/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW).

babygal
26th July 2010, 10:31
I'm not able to execute the command 'reimp' as per the instruction in the link . And where can I get the download files for the reimp?


Goto the sub-directory lib/opt and run reimp libmysql.lib to produce the liblibmysql.a file. This is the import library to use with MinGW.

saa7_go
26th July 2010, 11:28
You can download mingw-utils in http://sourceforge.net/projects/mingw/files/MinGW/Utilities/mingw-utils/mingw-utils-0.3/mingw-utils-0.3.tar.gz/download or http://sourceforge.net/projects/mingw/files/MinGW/Utilities/mingw-utils/mingw-utils-0.4-1/mingw-utils-0.4-1-mingw32-bin.tar.lzma/download.

babygal
27th July 2010, 10:18
How can I be sure that the driver files are installed correctly?

saa7_go
27th July 2010, 10:55
You can use QSqlDatabase::drivers() (http://doc.trolltech.com/4.6/qsqldatabase.html#drivers) to check all of the available drivers.

babygal
28th July 2010, 08:21
int main(int argc, char *argv[])
{

QApplication app(argc, argv);

qDebug() << QSqlDatabase::drivers();
if (!createConnection())
return 1;

Q_INIT_RESOURCE(cardiacprocessingtoolkit);
MainWindow mainWin;
mainWin.show();


return app.exec();
}

The debug message reads as:
("QSQLITE", "QMYSQL3", "QMYSQL", "QODBC3", "QODBC")

but the connection fails ! what's wrong?

Lykurg
28th July 2010, 08:53
but the connection fails ! what's wrong?Show us how you connect to your database and look at the error message.

babygal
28th July 2010, 10:27
Show us how you connect to your database and look at the error message.



static bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("DatabaseName");
if (!db.open()) {
QMessageBox::critical(0, qApp->tr("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n"
"This example needs MYSQL support. Please read "
"the Qt SQL driver documentation for information how "
"to build it.\n\n"
"Click Cancel to exit."), QMessageBox::Cancel);
return false;
}





return true;
}

saa7_go
28th July 2010, 11:49
Can you connect to your MySQL server using MySQL client (mysql.exe) without username and password? Make sure your database "DatabaseName" exist and MySQL service is running.

babygal
5th August 2010, 09:00
Can you connect to your MySQL server using MySQL client (mysql.exe) without username and password? Make sure your database "DatabaseName" exist and MySQL service is running.


No I am not able to connect.I've no idea what's wrong.

Lykurg
5th August 2010, 09:24
Then probably you have to start your server!

babygal
5th August 2010, 09:33
Read this guide (http://www.qtcentre.org/wiki/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW).

In this guide, there is a prerequisite:
Download the MySQL installer (the essentials msi-package is enough) from MySQL.com and install it (make sure to choose to install the headers as-well.
But there are many downloads in that site MySQL.com . Which one do I choose?

Lykurg
5th August 2010, 10:18
take the MySQL Community Server. It will have all necessary files.

babygal
5th August 2010, 10:33
take the MySQL Community Server. It will have all necessary files.

i downloaded and installed : mysql-5.1.49 - win32.msi

babygal
6th August 2010, 08:46
You can download mingw-utils in http://sourceforge.net/projects/mingw/files/MinGW/Utilities/mingw-utils/mingw-utils-0.3/mingw-utils-0.3.tar.gz/download or http://sourceforge.net/projects/mingw/files/MinGW/Utilities/mingw-utils/mingw-utils-0.4-1/mingw-utils-0.4-1-mingw32-bin.tar.lzma/download.


I download the mingw-utils in http://sourceforge.net/projects/ming...ar.gz/download .
As per the guide : http://www.qtcentre.org/wiki/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW
the second prerequisite is : Download the mingw-utils .Copy the contents of the binary tar.gz to %QTDIR%/bin.
My question is which bin folder exactly?There are a few bin folders. QT version I'm using is 2010.02.1

saa7_go
6th August 2010, 09:01
I assume your Qt installation is in C:\. So, copy your mingw-utils contents(in bin directory) in C:\Qt\2010.02.1\qt\bin.

babygal
6th August 2010, 10:26
I downloaded the MySQL Server 5.1 into path
C:\Program Files\MySQL\MySQL Server 5.1 .

But there is no \lib\opt\ in my :
C:\Program Files\MySQL\MySQL Server 5.1\lib.

Instruction from the guide link :-

How to Build the Plug-in :
-Open a Qt Command Prompt and go to wherever you installed the MySQL server (C:\Program Files\MySQL\MySQL Server 5.0 is the default location).
-Goto the sub-directory lib/opt and run reimp libmysql.lib to produce the liblibmysql.a file. This is the import library to use with MinGW.

But I do not find any sub-directory lib/opt . So how do I proceed?

saa7_go
6th August 2010, 10:33
Is there libmysql.lib in your MySQL lib directory ?

babygal
10th August 2010, 03:34
Is there libmysql.lib in your MySQL lib directory ?




No, there isn't ..

babygal
10th August 2010, 09:09
Have I installed the wrong files?I installed the mysql-5.1.49-win32.msi .

saa7_go
10th August 2010, 10:25
In your previous post,



int main(int argc, char *argv[])
{

QApplication app(argc, argv);

qDebug() << QSqlDatabase::drivers();
if (!createConnection())
return 1;

Q_INIT_RESOURCE(cardiacprocessingtoolkit);
MainWindow mainWin;
mainWin.show();


return app.exec();
}

The debug message reads as:
("QSQLITE", "QMYSQL3", "QMYSQL", "QODBC3", "QODBC")


Why do you look for libmysql.lib? You already have mysql plugin.

babygal
11th August 2010, 08:11
In your previous post,


Why do you look for libmysql.lib? You already have mysql plugin.




So what does that mean? I don't need the installation files?

confused.....

saa7_go
12th August 2010, 06:32
So what does that mean? I don't need the installation files?
confused.....
You don't need to rebuild QMYSQL plugin again, but you need MySQL server. Just, create(or use) a database, a table, inserting some record. Then, try to connect to mysql server using Qt, and see what happen(success or error).

babygal
12th August 2010, 06:57
You don't need to rebuild QMYSQL plugin again, but you need MySQL server. Just, create(or use) a database, a table, inserting some record. Then, try to connect to mysql server using Qt, and see what happen(success or error).

Do I need to do some configuration in my *.pro file to enable the MySql?

saa7_go
12th August 2010, 07:02
Do I need to do some configuration in my *.pro file to enable the MySql?

No, but you must add sql module in your .pro.



QT += sql

babygal
12th August 2010, 07:32
No, but you must add sql module in your .pro.



QT += sql


Thank you. I have added this line : QT += sql in my *.pro

The server is configured on another PC and my PC is supposedly the client. Does it make a difference in my code/project?

saa7_go
12th August 2010, 07:40
Does it make a difference in my code/project?
No. But, don't forget to set the correct hostname/ip where mysql server is installed.

babygal
12th August 2010, 11:55
Yayyy..Happy news ...it works ..my program can now connect to the mysql database on another server.
Thanks a million. and thanks for the patience replying my queries. Thanks!!!!