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. How to connect database to online service
Forum Updated to NodeBB v4.3 + New Features

How to connect database to online service

Scheduled Pinned Locked Moved Solved General and Desktop
28 Posts 4 Posters 5.0k Views 3 Watching
  • 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.
  • mrjjM mrjj

    Hi
    Each app is a mysql client so each would have its own connection to the DB.

    a JS "app" would be running at a server and that server is the mysql client for all
    browsers showing the pages.

    So no, there is not some Qt server that can do the same as its not quite the same setup.

    Thank YouT Offline
    Thank YouT Offline
    Thank You
    wrote on last edited by
    #3

    @mrjj
    Oh! thanks for the information. I am happy that you understood my problem.
    Do you know any database hosting providers which provides database hosting without any problems. It should be quite fast.

    OR
    Should I create host in local computer and serve it to other computers via local network

    Example;
    I have computer where mysql is hosted and other peoples connected on the same ROUTER can access it

    Which one would be best. I need it to be fast. So I guess second one will be fast and best alternative. Main drawback is we can't use from anywhere.

    Let's make QT free or It will go forever

    TRUE AND FALSE <3

    mrjjM 1 Reply Last reply
    0
    • Thank YouT Thank You

      @mrjj
      Oh! thanks for the information. I am happy that you understood my problem.
      Do you know any database hosting providers which provides database hosting without any problems. It should be quite fast.

      OR
      Should I create host in local computer and serve it to other computers via local network

      Example;
      I have computer where mysql is hosted and other peoples connected on the same ROUTER can access it

      Which one would be best. I need it to be fast. So I guess second one will be fast and best alternative. Main drawback is we can't use from anywhere.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #4

      @Thank-You
      Hi
      There are many that hosts mysql but I have not tried them.
      I heard their own service is super fast
      https://www.mysql.com/cloud/
      but also expensive.

      • Should I create host in local computer and serve it to other computers via local network

      If this is an option. Having the MQSQL within the network, from a security perspective and
      performance, it's way better than in the cloud.
      So yes if this is on the table, i would host locally. For safety, for speed, and for generally an easier setup.

      Thank YouT 1 Reply Last reply
      0
      • mrjjM mrjj

        @Thank-You
        Hi
        There are many that hosts mysql but I have not tried them.
        I heard their own service is super fast
        https://www.mysql.com/cloud/
        but also expensive.

        • Should I create host in local computer and serve it to other computers via local network

        If this is an option. Having the MQSQL within the network, from a security perspective and
        performance, it's way better than in the cloud.
        So yes if this is on the table, i would host locally. For safety, for speed, and for generally an easier setup.

        Thank YouT Offline
        Thank YouT Offline
        Thank You
        wrote on last edited by
        #5

        @mrjj

        I watched tutorials on local hosting but hadn't done succesfully.
        I am thinking of using Xampp for this purpose.
        Do you have any idea how to host database locally. (although it is offtopic from the question)
        I would be very happy to know about that thing

        Let's make QT free or It will go forever

        TRUE AND FALSE <3

        mrjjM 1 Reply Last reply
        0
        • Thank YouT Thank You

          @mrjj

          I watched tutorials on local hosting but hadn't done succesfully.
          I am thinking of using Xampp for this purpose.
          Do you have any idea how to host database locally. (although it is offtopic from the question)
          I would be very happy to know about that thing

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #6

          Hi
          Xampp is great but does your local server also need a web server?

          The easiest way to have a server is a virtual one.
          One way is to use dockers.
          https://www.docker.com/
          and then download a predefined setup
          https://hub.docker.com/r/mysql/mysql-server

          it would then be able to run anyware/any pc. Do not, learning to use Dockers takes
          a day or so but in the end its not that complicated and once running it can live forever.
          Even the pc that plays server dies. Simply run it on some other pc.

          However, what is the setup?
          Do you have an real server already or you must provide one ?

          Thank YouT 1 Reply Last reply
          0
          • mrjjM mrjj

            Hi
            Xampp is great but does your local server also need a web server?

            The easiest way to have a server is a virtual one.
            One way is to use dockers.
            https://www.docker.com/
            and then download a predefined setup
            https://hub.docker.com/r/mysql/mysql-server

            it would then be able to run anyware/any pc. Do not, learning to use Dockers takes
            a day or so but in the end its not that complicated and once running it can live forever.
            Even the pc that plays server dies. Simply run it on some other pc.

            However, what is the setup?
            Do you have an real server already or you must provide one ?

            Thank YouT Offline
            Thank YouT Offline
            Thank You
            wrote on last edited by
            #7

            @mrjj

            One way is to use dockers.

            I am somewhat aware about it. But main thing is
            My computer doesn't support it. I don't have virtualization in this PC.(So can't learn here) I will get new laptop within 2 months I guess. Currently It runs in Intel Dual Core 2.

            Even the pc that plays server dies.

            I am sure there will be no problem with it.
            I will run Xampp in the client machine. It runs pretty well in my machine. So that speed is sufficient for me.
            It will run in about 12 machines.

            However, what is the setup?
            Do you have an real server already or you must provide one ?

            No just windows machine. Nothing specific. If we need more user. They can give me different PC for hosting database(may be after using it for 2 months). So Xampp is best I guess for now.

            Let's make QT free or It will go forever

            TRUE AND FALSE <3

            mrjjM 1 Reply Last reply
            0
            • Thank YouT Thank You

              @mrjj

              One way is to use dockers.

              I am somewhat aware about it. But main thing is
              My computer doesn't support it. I don't have virtualization in this PC.(So can't learn here) I will get new laptop within 2 months I guess. Currently It runs in Intel Dual Core 2.

              Even the pc that plays server dies.

              I am sure there will be no problem with it.
              I will run Xampp in the client machine. It runs pretty well in my machine. So that speed is sufficient for me.
              It will run in about 12 machines.

              However, what is the setup?
              Do you have an real server already or you must provide one ?

              No just windows machine. Nothing specific. If we need more user. They can give me different PC for hosting database(may be after using it for 2 months). So Xampp is best I guess for now.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @Thank-You said in How to connect database to online service:

              Intel Dual Core 2.

              Wow thats a pretty old one.
              As far as I can recall, you can run virtual box on it 32 bit.
              but 64 bit demands VT-x.

              However, if Xampp works fine, i would just go with that. 12 clients is not that much.

              Thank YouT 1 Reply Last reply
              0
              • mrjjM mrjj

                @Thank-You said in How to connect database to online service:

                Intel Dual Core 2.

                Wow thats a pretty old one.
                As far as I can recall, you can run virtual box on it 32 bit.
                but 64 bit demands VT-x.

                However, if Xampp works fine, i would just go with that. 12 clients is not that much.

                Thank YouT Offline
                Thank YouT Offline
                Thank You
                wrote on last edited by
                #9

                @mrjj

                As far as I can recall, you can run virtual box on it 32 bit.

                Wow, Really I didn't know about that.

                Do you have any idea how can I do that?😂😂

                Let's make QT free or It will go forever

                TRUE AND FALSE <3

                mrjjM 1 Reply Last reply
                0
                • Thank YouT Thank You

                  @mrjj

                  As far as I can recall, you can run virtual box on it 32 bit.

                  Wow, Really I didn't know about that.

                  Do you have any idea how can I do that?😂😂

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @Thank-You

                  Well if you download virtual box and
                  create a new virtual machine for 32-bit linux.
                  Not all distros have 32 bit anymore.

                  then
                  From the VirtualBox Manager, find the Enable Nested VT-x/AMD-V check box on the Processor tab. To disable the feature, deselect the check box.

                  then you can run most 32-bit linux or windows.
                  just make sure mysql or Xampp is 32 bit

                  To fast test if it still work you can grab a 32 bit win 7 here and test with
                  https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

                  Thank YouT 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @Thank-You

                    Well if you download virtual box and
                    create a new virtual machine for 32-bit linux.
                    Not all distros have 32 bit anymore.

                    then
                    From the VirtualBox Manager, find the Enable Nested VT-x/AMD-V check box on the Processor tab. To disable the feature, deselect the check box.

                    then you can run most 32-bit linux or windows.
                    just make sure mysql or Xampp is 32 bit

                    To fast test if it still work you can grab a 32 bit win 7 here and test with
                    https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

                    Thank YouT Offline
                    Thank YouT Offline
                    Thank You
                    wrote on last edited by Thank You
                    #11

                    @mrjj
                    Hello Sir,
                    I have finalized my thoughts and thought to use Xampp.
                    I am stuck in small problem.
                    It's middle night here. But still I can't find any solutions of it.(Almost searched about this topic for 5-6 hours)

                    I have hosted on 192.168.100.8 But I want to make it fixed that it won't change.
                    Like just hosting database on 192.168.100.8 wherever I am connected In (local network, I should be able to access the port from another computer on the same network).
                    How can I make it host to fixed private Ip in LAN at any time
                    Or
                    Will it change overtime If so how can I solve this problem.

                    Let's make QT free or It will go forever

                    TRUE AND FALSE <3

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      Hi,

                      Use a proper DNS and name your server appropriately. Otherwise you have to make the address static.

                      In any case, you have to take another thing into account, if you want to connect to your database through the internet, you should really consider implementing a proper service that will shield the database from the internet.

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

                      Thank YouT 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        Hi,

                        Use a proper DNS and name your server appropriately. Otherwise you have to make the address static.

                        In any case, you have to take another thing into account, if you want to connect to your database through the internet, you should really consider implementing a proper service that will shield the database from the internet.

                        Thank YouT Offline
                        Thank YouT Offline
                        Thank You
                        wrote on last edited by
                        #13

                        @SGaist

                        Yup, But main thing is I am not able to communicate to server.
                        I have hosted it successfully. But can't connect to server

                        I can go to

                        192.168.100.4:8080/phpmyadmin

                        and it shows as expected. But when I try to connect to database It fails
                        saying

                        53a55e2f-2888-46f7-ba79-90f09606931c-image.png

                           db.setDatabaseName("users");
                           db.setPort(8080);
                           db.setHostName("192.168.100.4");
                           db.setUserName("root");
                           db.setPassword("");
                        

                        What do you think the problem is?

                        Let's make QT free or It will go forever

                        TRUE AND FALSE <3

                        mrjjM 1 Reply Last reply
                        0
                        • Thank YouT Thank You

                          @SGaist

                          Yup, But main thing is I am not able to communicate to server.
                          I have hosted it successfully. But can't connect to server

                          I can go to

                          192.168.100.4:8080/phpmyadmin

                          and it shows as expected. But when I try to connect to database It fails
                          saying

                          53a55e2f-2888-46f7-ba79-90f09606931c-image.png

                             db.setDatabaseName("users");
                             db.setPort(8080);
                             db.setHostName("192.168.100.4");
                             db.setUserName("root");
                             db.setPassword("");
                          

                          What do you think the problem is?

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          @Thank-You
                          Hi
                          try with port 3306.

                          You are using port 8080 for
                          db.setPort(8080);

                          but is that not the port the web server uses ?
                          so while 192.168.100.4:8080/phpmyadmin Works, that is the port the web server answers
                          and not to mysql clients.

                          Also make sure port 3306 is not blocked by windows firewall.

                          https://dev.mysql.com/doc/mysql-port-reference/en/mysql-ports-reference-tables.html

                          Thank YouT 1 Reply Last reply
                          3
                          • mrjjM mrjj

                            @Thank-You
                            Hi
                            try with port 3306.

                            You are using port 8080 for
                            db.setPort(8080);

                            but is that not the port the web server uses ?
                            so while 192.168.100.4:8080/phpmyadmin Works, that is the port the web server answers
                            and not to mysql clients.

                            Also make sure port 3306 is not blocked by windows firewall.

                            https://dev.mysql.com/doc/mysql-port-reference/en/mysql-ports-reference-tables.html

                            Thank YouT Offline
                            Thank YouT Offline
                            Thank You
                            wrote on last edited by
                            #15

                            @mrjj
                            Yes, I actually got success after seeing this thing for almost day.

                               db.setDatabaseName("users");
                               db.setPort(9906);
                            // It  is 9906 because I changed from 3306 to 9906 before some time due to some errors
                               db.setHostName("192.168.100.4");
                               db.setUserName("host");
                               db.setPassword("");
                            

                            I first did what you said

                            changed to 9906(port)

                            And I got the error
                            322a9fd6-006e-401a-8c2e-4e15d0675ce2-image.png

                            Then I created new privileges to all address

                            Now It's finally done!

                            Ok I made it work but Are there security risks in this situation(simple only) ?
                            Another question for you

                            Will private IP change overtime.

                            If so there will be problem because the database won't be hosted if IP changes.
                            Am I right?. Or
                            It will be hosted on the same port?

                            Let's make QT free or It will go forever

                            TRUE AND FALSE <3

                            mrjjM SGaistS 2 Replies Last reply
                            0
                            • Thank YouT Thank You

                              @mrjj
                              Yes, I actually got success after seeing this thing for almost day.

                                 db.setDatabaseName("users");
                                 db.setPort(9906);
                              // It  is 9906 because I changed from 3306 to 9906 before some time due to some errors
                                 db.setHostName("192.168.100.4");
                                 db.setUserName("host");
                                 db.setPassword("");
                              

                              I first did what you said

                              changed to 9906(port)

                              And I got the error
                              322a9fd6-006e-401a-8c2e-4e15d0675ce2-image.png

                              Then I created new privileges to all address

                              Now It's finally done!

                              Ok I made it work but Are there security risks in this situation(simple only) ?
                              Another question for you

                              Will private IP change overtime.

                              If so there will be problem because the database won't be hosted if IP changes.
                              Am I right?. Or
                              It will be hosted on the same port?

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by mrjj
                              #16

                              Hi

                              • Ok I made it work but Are there security risks in this situation(simple only) ?

                              Depends on what you did. if you allowed this port in the firewall on the internal network/pc
                              its ok. That's how one normally allows new traffic on a port.

                              • Will private IP change overtime.

                              Yes. if done by the local DHCP server then yes unless some IT dude promised you
                              it would not. You can be lucky that it will get the same IP for a long time.

                              • If so there will be problem because the database won't be hosted if IP changes.

                              well if the IP changes then the clients cant find the server anymore.

                              But I don't know your LAN. if it's not a home setup then you most likely also have a DNS server and that means you can use a name instead of an IP. the DNS server will then translate the name to the Ip and hence
                              the actual IP is no longer important.

                              • It will be hosted on the same port?

                              Yes unless you change it yourself, port remains the same.

                              Thank YouT 1 Reply Last reply
                              0
                              • mrjjM mrjj

                                Hi

                                • Ok I made it work but Are there security risks in this situation(simple only) ?

                                Depends on what you did. if you allowed this port in the firewall on the internal network/pc
                                its ok. That's how one normally allows new traffic on a port.

                                • Will private IP change overtime.

                                Yes. if done by the local DHCP server then yes unless some IT dude promised you
                                it would not. You can be lucky that it will get the same IP for a long time.

                                • If so there will be problem because the database won't be hosted if IP changes.

                                well if the IP changes then the clients cant find the server anymore.

                                But I don't know your LAN. if it's not a home setup then you most likely also have a DNS server and that means you can use a name instead of an IP. the DNS server will then translate the name to the Ip and hence
                                the actual IP is no longer important.

                                • It will be hosted on the same port?

                                Yes unless you change it yourself, port remains the same.

                                Thank YouT Offline
                                Thank YouT Offline
                                Thank You
                                wrote on last edited by
                                #17

                                @mrjj

                                if it's not a home setup then you most likely also have a DNS server

                                It's home server. A router that we use for normal purpose.
                                With this I want to host this database to other users connected to the same router.

                                Let's make QT free or It will go forever

                                TRUE AND FALSE <3

                                jsulmJ mrjjM 2 Replies Last reply
                                0
                                • Thank YouT Thank You

                                  @mrjj

                                  if it's not a home setup then you most likely also have a DNS server

                                  It's home server. A router that we use for normal purpose.
                                  With this I want to host this database to other users connected to the same router.

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #18

                                  @Thank-You said in How to connect database to online service:

                                  A router that we use for normal purpose

                                  Depending on the router you can assign static IPs to network devices.

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

                                  1 Reply Last reply
                                  1
                                  • Thank YouT Thank You

                                    @mrjj

                                    if it's not a home setup then you most likely also have a DNS server

                                    It's home server. A router that we use for normal purpose.
                                    With this I want to host this database to other users connected to the same router.

                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #19

                                    It's home server. A router that we use for normal purpose.

                                    Ok. you can most likely make it assign a fixed ip to the server so it never changes.
                                    If it cant directly, you can often change the range of ips it will give out and
                                    then use an ip outside of this range and hence keep it.

                                    • With this I want to host this database to other users connected to the same router.

                                    Wait ? from outside ? Like from the internet ?

                                    Thank YouT 1 Reply Last reply
                                    0
                                    • Thank YouT Thank You

                                      @mrjj
                                      Yes, I actually got success after seeing this thing for almost day.

                                         db.setDatabaseName("users");
                                         db.setPort(9906);
                                      // It  is 9906 because I changed from 3306 to 9906 before some time due to some errors
                                         db.setHostName("192.168.100.4");
                                         db.setUserName("host");
                                         db.setPassword("");
                                      

                                      I first did what you said

                                      changed to 9906(port)

                                      And I got the error
                                      322a9fd6-006e-401a-8c2e-4e15d0675ce2-image.png

                                      Then I created new privileges to all address

                                      Now It's finally done!

                                      Ok I made it work but Are there security risks in this situation(simple only) ?
                                      Another question for you

                                      Will private IP change overtime.

                                      If so there will be problem because the database won't be hosted if IP changes.
                                      Am I right?. Or
                                      It will be hosted on the same port?

                                      SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #20

                                      @Thank-You said in How to connect database to online service:

                                      Then I created new privileges to all address

                                      Depending on how you did that you allowed user from anywhere to connect to your database which might not be what you want.

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

                                      Thank YouT 1 Reply Last reply
                                      1
                                      • SGaistS SGaist

                                        @Thank-You said in How to connect database to online service:

                                        Then I created new privileges to all address

                                        Depending on how you did that you allowed user from anywhere to connect to your database which might not be what you want.

                                        Thank YouT Offline
                                        Thank YouT Offline
                                        Thank You
                                        wrote on last edited by
                                        #21

                                        @SGaist

                                        PRIVILEGES ON *.* FROM 'host'@'%';
                                        

                                        It is shown while I was updating
                                        I am sorry I did it with PHPMYADMIN So I don't know syntax much of this thing

                                        CREATE USER 'demo'@'%' IDENTIFIED VIA mysql_native_password USING '***';
                                        GRANT ALL PRIVILEGES ON *.* TO 'demo'@'%' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
                                        GRANT ALL PRIVILEGES ON `users`.* TO 'demo'@'%'; 
                                        

                                        I recreated another one for showing.

                                        Let's make QT free or It will go forever

                                        TRUE AND FALSE <3

                                        1 Reply Last reply
                                        0
                                        • mrjjM mrjj

                                          It's home server. A router that we use for normal purpose.

                                          Ok. you can most likely make it assign a fixed ip to the server so it never changes.
                                          If it cant directly, you can often change the range of ips it will give out and
                                          then use an ip outside of this range and hence keep it.

                                          • With this I want to host this database to other users connected to the same router.

                                          Wait ? from outside ? Like from the internet ?

                                          Thank YouT Offline
                                          Thank YouT Offline
                                          Thank You
                                          wrote on last edited by
                                          #22

                                          @mrjj said in How to connect database to online service:

                                          Wait ? from outside ? Like from the internet ?

                                          No, Just within the network only.
                                          Like how you use WIFI. (Available to only peoples in the LOCAL NETWORK)

                                          If you didn't understand this,
                                          Let me give an example

                                          Suppose I am connected to the WIFI(router). And you are also connected to the same wifi. I have hosted the database. You can use this database only if you are connected to the same wifi/router that I have hosted into. You are not allowed to access this outside of this network. If you get disconnected with network I won't be able to connect with it.

                                          I hope you understands

                                          Let's make QT free or It will go forever

                                          TRUE AND FALSE <3

                                          mrjjM 1 Reply Last reply
                                          0

                                          • Login

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