Is your MySql server listening on a TCP socket at all? The console may be using a local socket/pipe to connect to the server and not a TCP socket.
Is your MySql server listening on a TCP socket at all? The console may be using a local socket/pipe to connect to the server and not a TCP socket.
Hi Wyosota,
Sorry didn't quite get it.
Can you explain it in a bit more detail.
And how do I check the above to things?
Regards
Zia
In configuration file my.ini in windows or my.cnf in linux there is an option named "skip-networking" which is enabled by default for security reasons. Comment it by placing a # before so as to enable tcp-connection.
Hi RHayader,
It is off as can you can see in the attached output of the command
Hi RHayder,
The "skip-networking" is already OFF as can be seen from the attached output of 'myadmin variable -u root -p'
regards
Zia
Added after 11 minutes:
Hi,
Also find attached file countaining output of 'mysqladmin variable -u root -p'
Regards
Zia
Last edited by syedzia5; 9th September 2012 at 04:23.
Are you able to connect to the server using a simple C program such as this?
Qt Code:
#include <mysql.h> int main(int argc, char **argv) { MYSQL mysql; mysql_init(&mysql); if(!mysql_connect(&mysql, "localhost", "root", NULL)) { printf("%s\n", mysql_error(&mysql)); return 1; } printf("Connection ok\n"); return 0; }To copy to clipboard, switch view to plain text mode
Compile with:
gcc main.c -I/usr/include/mysql -lmysqlclient -o testconnection
or equivalent.
It didn't workIt didn't connect
I tried following code:
Qt Code:
#include <QtCore/QCoreApplication> #include <winsock2.h> #include <ws2tcpip.h> #include <stdio.h> #include <mysql.h> int main(int argc, char *argv[]) { MYSQL mysql; mysql_init(&mysql); if(!mysql_real_connect(&mysql, "localhost", "root", "zrsyed15967", "test", 3306,NULL,CLIENT_MULTI_STATEMENTS)) { printf("%s\n", mysql_error(&mysql)); return 1; } return a.exec(); }To copy to clipboard, switch view to plain text mode
Since the mysql lib installation on my windows m/c doesn't has mysql_connect, I have used mysql_real_connect and this is used by QSqlDatabase class also.
The Library I am using is ConnectorC6.0.2.
"It didn't work," is not a useful description. What was the error message printed? What have you done to diagnose the problem with your MySql instance?
This problem no longer has anything to do with Qt.
If the host name is "localhost" or NULL then a connection is attempted using shared memory (Windows) or local socket (UNIX) in preference to a TCP connection (http://dev.mysql.com/doc/refman/5.0/...l-connect.html). To force a TCP connection you must use "127.0.0.1" or another name that resolves to the machine.
I agree that this has not got to do with Qt. There are many reasons that you cannot connect to MySQL server and most of them are referenced in http://dev.mysql.com/doc/refman/5.5/...to-server.html.
Maybe you are running more than one instance of MySQL server if you upgraded from a previous version. And as ChrisW67 suggested tryQt Code:
mysqladmin -h 127.0.0.1 version variablesTo copy to clipboard, switch view to plain text mode
Bookmarks