Qt Remote Database connection
-
How to solve the error QSqlError("2003", "QMYSQL: Unable to connect", "Can't connect to MySQL server on '112.17.98.18' (111)")
When i connecting the remote database it shows the error that given above.But when i connecting the localhost it does not show any error. given below my code.Please help me
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("112.17.98.18"); // fake ip ;
db.setPort(3306);
db.setDatabaseName("root");
db.setUserName("root");
db.setPassword(" ");
db.open(); -
@Tonny said in Qt Remote Database connection:
But when i connecting the localhost it does not show any error
And does it connect then?
Did you try to connect using MySQL client? -
Hi and welcome to devnet forum
Did you check already with a local MySQL db and does it work?
For remote connection you have the classical obstacles like firewall (on both sides) and possibly a virus scanner.
Can you access the database through MySQL workbench without problems or warnings? -
@Tonny said in Qt Remote Database connection:
112.17.98.18
Is connectivity to remote server(112.17.98.18) exist ? Can you ping the 112.17.98.18 ? If yes, can you do 'telnet 112.17.98.18 111' from command to check it works. Can you check with some third party tools like DataBase Explorer to connect and query your remote DB ?
-
Hi,
To add to my fellow, did you also configure your remote database to accept connection from the outside ?
IIRC, accounts like root are only available for local connection.
-
@dheerendra Sir when i type the command telnet it shows the error that 'telnet: Unable to connect to remote host: Connection refused'.I don't know what is the problem.Please help me sir
-
Are you able to do ping to remote server ping 112.17.98.18 ?
-
@dheerendra ping command is successfully run,But Telnet is not worked
-
112.17.98.18 is this in LAN ? Hope there is no firewall etc between your box and 112.17.98.18.
Since telnet is not able to connect to port 111 are you sure that SQL is running at the port 111 ? -
@dheerendra
Sir SQL is not running in the port 111.Sql port is 3306 .. -
OK can you check telnet 112.17.98.18 3306 ? Does it work ? If it work, atleast DB is up at that port.
-
@dheerendra sir it shows telnet: Unable to connect to remote host: Connection refused
-
If you have access to the DB Server box, can you login to the system. In same system can you try to do telnet <IP> Port#. Just check the configuration of the remote sql server. Is it configured to listen for network connections also ?
-
@Tonny said in Qt Remote Database connection:
mysql client?Please give the procedure to connect it.
-
@dheerendra Sir error solved.
Sir can you please tell me how to sent values through http protocol using qt creator in the REST API
please?Is there any solution for that sir -
What was the issue ? Please provide the details here. It helps others. You can move the issue to SOLVED state.
-
@dheerendra bind address commented. it was 127.0.0.1 (/etc/mysql/mysql.cnf);
-
Your server was configured to listen only for local IP address. You tried to connect to server remotely. This was the issue.