Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Remote Database connection
Forum Update on Monday, May 27th 2025

Qt Remote Database connection

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 6 Posters 5.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tonny
    wrote on 4 Dec 2018, 11:29 last edited by
    #1

    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();

    J K 2 Replies Last reply 4 Dec 2018, 11:38
    0
    • T Tonny
      4 Dec 2018, 11:29

      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();

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 4 Dec 2018, 11:38 last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply 5 Dec 2018, 05:56
      0
      • T Tonny
        4 Dec 2018, 11:29

        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();

        K Offline
        K Offline
        koahnig
        wrote on 4 Dec 2018, 11:38 last edited by
        #3

        @Tonny

        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?

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 4 Dec 2018, 12:04 last edited by
          #4

          @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 ?

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          T 1 Reply Last reply 5 Dec 2018, 04:58
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 4 Dec 2018, 17:53 last edited by
            #5

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • D dheerendra
              4 Dec 2018, 12:04

              @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 ?

              T Offline
              T Offline
              Tonny
              wrote on 5 Dec 2018, 04:58 last edited by
              #6

              @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

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dheerendra
                Qt Champions 2022
                wrote on 5 Dec 2018, 05:00 last edited by
                #7

                Are you able to do ping to remote server ping 112.17.98.18 ?

                Dheerendra
                @Community Service
                Certified Qt Specialist
                http://www.pthinks.com

                T 1 Reply Last reply 5 Dec 2018, 05:43
                0
                • T Offline
                  T Offline
                  Tonny
                  wrote on 5 Dec 2018, 05:23 last edited by
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • D dheerendra
                    5 Dec 2018, 05:00

                    Are you able to do ping to remote server ping 112.17.98.18 ?

                    T Offline
                    T Offline
                    Tonny
                    wrote on 5 Dec 2018, 05:43 last edited by
                    #9

                    @dheerendra ping command is successfully run,But Telnet is not worked

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dheerendra
                      Qt Champions 2022
                      wrote on 5 Dec 2018, 05:54 last edited by
                      #10

                      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
                      @Community Service
                      Certified Qt Specialist
                      http://www.pthinks.com

                      T 1 Reply Last reply 5 Dec 2018, 06:10
                      0
                      • J jsulm
                        4 Dec 2018, 11:38

                        @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?

                        T Offline
                        T Offline
                        Tonny
                        wrote on 5 Dec 2018, 05:56 last edited by
                        #11

                        @jsulm mysql client?Please give the procedure to connect it.

                        J 1 Reply Last reply 5 Dec 2018, 08:07
                        0
                        • D dheerendra
                          5 Dec 2018, 05:54

                          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 ?

                          T Offline
                          T Offline
                          Tonny
                          wrote on 5 Dec 2018, 06:10 last edited by
                          #12

                          @dheerendra
                          Sir SQL is not running in the port 111.Sql port is 3306 ..

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            dheerendra
                            Qt Champions 2022
                            wrote on 5 Dec 2018, 06:12 last edited by
                            #13

                            OK can you check telnet 112.17.98.18 3306 ? Does it work ? If it work, atleast DB is up at that port.

                            Dheerendra
                            @Community Service
                            Certified Qt Specialist
                            http://www.pthinks.com

                            T 1 Reply Last reply 5 Dec 2018, 06:30
                            0
                            • D dheerendra
                              5 Dec 2018, 06:12

                              OK can you check telnet 112.17.98.18 3306 ? Does it work ? If it work, atleast DB is up at that port.

                              T Offline
                              T Offline
                              Tonny
                              wrote on 5 Dec 2018, 06:30 last edited by
                              #14

                              @dheerendra sir it shows telnet: Unable to connect to remote host: Connection refused

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                dheerendra
                                Qt Champions 2022
                                wrote on 5 Dec 2018, 06:54 last edited by
                                #15

                                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 ?

                                Dheerendra
                                @Community Service
                                Certified Qt Specialist
                                http://www.pthinks.com

                                T 1 Reply Last reply 6 Dec 2018, 08:15
                                0
                                • T Tonny
                                  5 Dec 2018, 05:56

                                  @jsulm mysql client?Please give the procedure to connect it.

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 5 Dec 2018, 08:07 last edited by
                                  #16

                                  @Tonny said in Qt Remote Database connection:

                                  mysql client?Please give the procedure to connect it.

                                  https://dev.mysql.com/doc/refman/8.0/en/mysql.html

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • D dheerendra
                                    5 Dec 2018, 06:54

                                    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 ?

                                    T Offline
                                    T Offline
                                    Tonny
                                    wrote on 6 Dec 2018, 08:15 last edited by
                                    #17

                                    @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

                                    J 1 Reply Last reply 6 Dec 2018, 09:02
                                    0
                                    • D Offline
                                      D Offline
                                      dheerendra
                                      Qt Champions 2022
                                      wrote on 6 Dec 2018, 08:17 last edited by
                                      #18

                                      What was the issue ? Please provide the details here. It helps others. You can move the issue to SOLVED state.

                                      Dheerendra
                                      @Community Service
                                      Certified Qt Specialist
                                      http://www.pthinks.com

                                      T 1 Reply Last reply 6 Dec 2018, 08:45
                                      0
                                      • D dheerendra
                                        6 Dec 2018, 08:17

                                        What was the issue ? Please provide the details here. It helps others. You can move the issue to SOLVED state.

                                        T Offline
                                        T Offline
                                        Tonny
                                        wrote on 6 Dec 2018, 08:45 last edited by
                                        #19

                                        @dheerendra bind address commented. it was 127.0.0.1 (/etc/mysql/mysql.cnf);

                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          dheerendra
                                          Qt Champions 2022
                                          wrote on 6 Dec 2018, 08:52 last edited by
                                          #20

                                          Your server was configured to listen only for local IP address. You tried to connect to server remotely. This was the issue.

                                          Dheerendra
                                          @Community Service
                                          Certified Qt Specialist
                                          http://www.pthinks.com

                                          1 Reply Last reply
                                          0

                                          2/22

                                          4 Dec 2018, 11:38

                                          topic:navigator.unread, 20
                                          • Login

                                          • Login or register to search.
                                          2 out of 22
                                          • First post
                                            2/22
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved