How to connect database to online service
-
@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. -
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 -
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-serverit 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 ? -
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.
-
@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.
-
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 bitTo 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/ -
@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 on192.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. -
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.
-
Yup, But main thing is I am not able to communicate to server.
I have hosted it successfully. But can't connect to serverI can go to
192.168.100.4:8080/phpmyadmin
and it shows as expected. But when I try to connect to database It fails
sayingdb.setDatabaseName("users"); db.setPort(8080); db.setHostName("192.168.100.4"); db.setUserName("root"); db.setPassword("");
What do you think the problem is?
-
@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
-
@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
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 youWill 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? -
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-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.
-
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-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.
-
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 thingCREATE 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.
-
@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 exampleSuppose 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
-
@Thank-You
Ah
Ok super. That will work fine then.
Yes I understand fully :)If you know the 10 clients pc. you can take their mac address and
tell the router to only allow those MAC addresses to the MySQL port.
That will block all others-