I created a mySQL database on one machine in my local network. Lets say, I install my application on a friends computer at his house. I have a computer set up as a server running the mySQL database at my house. If that computer is running, how can I make my friends computer send and receive data from the mySQL database on my network?
I am using JDBC and the J connector. I currently can connect to the database with JDBC, so I am currently good with that.
How can I make my friends computer send and receive data from the mySQL database on my network? Will I need a service like Google Cloud SQL or is there any other free way?I also want to make it so that I can email any friend with the program, and they can install it and the program connects to the MySQL server without Andy router extensional. Is a MySQL database even the way to go?
Edit: Basically, I made an MySQL database on a local computer and am able to save data to it from a JDBC program. I want the SQL database to be online so if I send the program to somebody else, they can open it and it accesses the online database. How should I go about making an online SQL database which has no limitations on what IP address accesses it?
Assuming you have a NAT router connecting your local network to the Internet, set up port forwarding on your router to forward port 3306 to the database machine on your network.
Then your friend would specify your router's public IP as the hostname when making the database connection.
In your MySQL configuration, you'll need to create a user username#your-friend's-IP, and grant it access to your your database tables.
A MySQL client (the thing running on your friend's local network) initiates a connection to a MySQL server by requesting a TCP connection on port 3306 (usually).
So your friend's computer has to be able to initiate a connection to your computer. Most home networks have routers between them and the internet service provided. Routers, unless specially configured, ignore attempts to connect from the public internet.
You need to configure your router to pass port 3306 connections through to your computer. Then you need to figure out the ip address by which your internet service provider addresses your router and your friend's router (usually the router user interface will tell you this). Then you need to set up a username / ip address / password triple on your MySQL database authorizing your friend to connect.
Finally, keep in mind that your internet service provider probably assigns both of you dynamic ip addresses; they might change.
Related
I have a set of data rolling out of Node-Red that I want to send to a remote MYSQL database. The Node-Red system is running on a Raspberry Pi. How do I make this work? I know how to it using Node.JS but im not sure how to do this in Node-Red. The IP-adress of the Pi is dynamic so simply authorizing its Ip address does not work sadly.
Thanks in advance!
EDIT for clarification:
I want to connect to a remote MYSQL database that is hosted by my webhosting. I have connected a Raspberry Pi to a battery, and I want to save this information in the aforementioned database. Since there will be several battery setups in different locations, I cannot save the data locally. So, one way or another I need to access the remote database through Node-Red. Authorizing one IP-address does't work, since the IP of the Raspberry Pi network is dynamic and thus changes. I think a SSH-Tunnel might be the solution, but I have no idea how to this in Node-Red, and google isnt very helpful.
OK, so as I said in the comments you can make a Username/Password pair for MySQL can be granted permission to any IP address (which is less secure if the username/password is compromised. Set the host to '%' to allow all hosts when setting up the grant options).
To reduce the risk you can restrict the Username/Password to a specific subnet. This could be a wifi network or the subnet associated to the piblic IP (it needs to be the public range as nearly all cellular ISPs use CGNAT) range of the cellular provider you may be using. (See this question for details How to grant remote access to MySQL for a whole subnet?).
If you want to use a SSH tunnel then this will normally be done outside Node-RED with the ssh command line e.g.
ssh -L localhost:3306:localhost:3306 remote.host.com
Then configure the Node-RED MySQL node to point to localhost.
Since the connection will look like it's coming from localhost on the MySQL machine you need make sure the Username/Password is locked down to a that host.
You will probably also want to set up public/private key authentication for the ssh connection.
You may be able to run the ssh command in the node-red-daemon node, which should restart the connection if it gets dropped.
I am using a software - (Ingress) by FingerTec which uses mysql database.
Some setups of this system are only using a single installation - consisting of a mysql server and a client locally on the same machine.
I have been having issues since I started to use the software when it is installed on a user's laptop/PC. The problem is that frequently when running the mysql server and client, a window pops up asking for the local IP address and port (127.0.0.1 and 3306 by default). To continue using the software, one needs to run IngressDB installer where you need to 'Update Connection' by giving the root user and pass for mysql and then 'Upgrade Database' to refresh the database for any new settings. After this step the software runs fine.
Yesterday I managed to simulate this issue by changing the static IP on my laptop while connected directly to one of their Access Controllers. I had to re-Run Ingress DBinstaller.
Now my question is this:
When using your machine(laptop/pc) it is normally getting IP add, def GW, Subnet etc from a dhcp server therefore there is no guarantee that you will always get the same IP leased unless there is a reservation to the machine's mac address.
As described earlier - when ever there is a change of IP address leased from DHCP, a window pops up showing the loopback address 127.0.0.1 and the mysql port 3306. So it never shows the local IP address (ex. 192.168.1.100). So I was thinking - why is the loopback IP not enough for mysql client/server as this stays the same forever.
Is is normal that software using mysql database server requires a static local IP on the machine hosting it? I am referring only to instances where both mysql server and client reside on the same machine.
I appreciate your thoughts about this and maybe any other way I can get around this apart from making an IP address reservation in the DHCP server. Setting a static IP address manually on the LAN adapter is no solution for me as this would limit the machine to connect only to a certain network and cannot be used at other places.
If the client is the same local machine as the server, the MYSQL server specifically does not need a static IP because it pretty much already has one: 'localhost' or '127.0.0.1'. If the client is not on the same machine as the server, the server would need a static IP.
If the machine is acting as a server for other content, yes, it would need a static IP. If you're doing this at home, chances are that your access point will let you configure it for a static IP.
I'd like to know how to connect the client pc in a outside network for example a WAM network, i have my database in my pc and i use this like the server. I know how to connect mysql with another client computer inside the LAN network but i dont know how to do it like the other way.
if you don't understand something make me know.
PD: sorry for my english is my first question on a english forum
Ultimately it works exactly the same way - you need an IP address and a port to connect to your database on. You can either do this by setting up port-forwarding at the firewall on the network with the database server (basically, forward port 3306 to the LAN IP address), or by giving the database server a publicly available static IP and then opening port 3306 in any firewalls. Alternatively, you can set up a VPN to the network with the database server, and connect through this. If done right, the VPN option is much more secure.
However, you should ask yourself why you want to do this. Is your idea to have a client software that directly connects to the database? This is not a great design - it's usually better to have a backend database that is accessed via a frontend API (e.g. a RESTful API or similar). Among other benefits, this can give you much better (finer-grained) access control to the database.
Your MySql server should have a firewall rule to accept outside connection on MySql port (default is 3306). Best setup should allow connection from your clients WAN address only.
Then, your C# connector will be able to connect just the same as in LAN.
I would like to push sensor data from the raspberry pi to localhost phpmyadmin. I understand that I can install the mysql and phpmyadmin on the raspberry pi itself. But what I want is to access my local machine's database in phpmyadmin from the raspberry pi. Would it be possible?
Well, from what I understand, you'd like to save the sensor data arriving in your Raspberry Pi to a database and access it from another machine. What I suggest is, install a mysql db instance and phpmyadmin in your Raspberry Pi and you can access phpmyadmin from another machine in the network by using the RPi's ip address.
Hope this is what you wanted to do.
Sure, as long as they're on the same network and you have granted proper permission, all you have to do is use the proper hostname or IP address of the MySQL server (what you call the local machine). In whatever utility or custom script you have that writes data, use the networked IP address instead of 127.0.0.1 or localhost for the database host.
Depending on how you've installed MySQL, you may not have a user that listens for non-local connections, incoming MySQL connections may be blocked at the firewall, or your MySQL server may not listen for incoming network connections.
You've asked about using phpMyAdmin from the Pi, accessing your other computer, which doesn't seem to make much sense to me (I'd think you'd want to run phpMyAdmin on your desktop computer, not a Pi), but if you've got a GUI and compatible web browser running on the Pi then you'd just have phpMyAdmin and the webserver run on the same desktop computer that has MySQL and access that hostname and folder from the Pi (such as http://192.0.2.15/phpmyadmin).
If you're planning to make the MySQL server itself public-facing, you should really re-think that decision unless you know why that's a bad idea and how to properly secure it (but that may not be a concern; for instance I have one at home that is available on the local network, but my router blocks any incoming connections from external sources).
I have a database in my localhost(Use WAMP server).I have created a WiFi network among several laptops.There is a C# application on client laptop which need to use the database in server(This application uses the data in the database).How do I do this?
(The client laptop can connect to my wamp server through browser successfully with address
192.168.16.2).
You need to do three things
Ensure that the application has the correct details to make the connection i.e username, password, database and hostname
Ensure that the server is using TCP/IP protocol (perhaps SSL) and that the firewall will not prevent incomming connections.
Ensure that the database user can connect from the remote machine. This can be achieved using the Workbench application.