简体   繁体   中英

MySql Raspberry Pi Connection from Outsitde LAN

I set up a MySql database at my Raspberry Pi 2 today. I created a database with tables etc. When I am connection to the MySql pi server over LAN with 196.168... it works. (I am using MySql Workbench 6.3 CE) But I want to use the MySql server for my C# Application, so where ever the Application lies, it have to be able to connect to the database, so I thought I need to connect over the "Plublic" IP. But logical the public IP from the Raspberry Pi is the same as mine (from pc) because we are in the same subnet...

So it is logical for me that the "connector" doesnt know where to connect (at which host), so what "IP" do I use to connect to the MySql Pi Server wherever I am?

May be a stupid questions but it insterest me and I didnt find a answer for that.

You will need to forward ports on your router to allow incoming traffic. The internet would be a much more dangerous place if you could access any computer in any network as if it were a public server. So, when you connect locally, all of that is happening behind the router from one trusted source to another, but to connect from anywhere else, you need to tell the router to allow incoming traffic on a certain port to go through to a certain device.

I cannot help you completely solve your problem as I don't know your exact setup, but if you'd like to learn more about that solution you can start by reading about port forwarding in general: https://en.wikipedia.org/wiki/Port_forwarding

Another option is to use a tunnel solution. This would be a solution that establishes a connection from inside your local network, to a front-end service outside of your network, and would allow traffic to go to your pi via a public-facing address. I use such a service myself, it's called Pagekite . I'm not affiliated with them but I use it extensively on lots of pi's behind many different firewalls. You basically install their program on the pi, and allow outside traffic to be relayed to your database server's port from a public address like address.pagekite.me .

I know it's not a complete answer but hopefully it will point you in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM