connect to mysql database on my home computer from college - mysql

I am a freshman in computer science, so bear with me. sorry.
I have installed MySQL on my windows 7 machine. Installed are Server/Workbench/Utilities/Shell/Router
I have created a test database (schema?) and called it test. I have been able to use the shell (just put password in) to run some commands to verify I am creating some test tables and stuff. I have also been able to use Workbench to access what I have created. It says "Local instance MY SQL Router / root / localhost:3306"
Now that is all very well and good. But how do I access this database (or is it server?? I don't know what my server is called) I have created on my home computer from college computers?
my college computer labs will also have MySQL workbench. I will be keep home computer on if I want to access it from campus.

I hope you use a router at home, with a firewall. Otherwise your home system will quickly get pwned by hackers. I once turned on logging on my firewall to show me how often I was being probed by illicit requests looking for vulnerabilities. I had to turn off the log because it was taking up too much space after a few hours.
Your router will also need to be configured to forward requests to your Windows PC, because the public IP address is just for the router itself. The individual PC's on your home network are all hidden behind that router using NAT. So they each have an internal IP address like 192.168.0.110, but clients from the outside world can't reach that.
So you need to tell the router that when requests come in (at least for the specific port 3306 for MySQL), then forward that to your PC on 192.168.0.110 (or whatever IP address it has been assigned by your router). You should read the manual on your router to find out how to do this, because it's different in every brand of router.
Your Windows PC also has a firewall. It undoubtedly blocks the MySQL port 3306 by default. You will need to allow incoming requests on that port. See https://www.tomshardware.com/news/how-to-open-firewall-ports-in-windows-10,36451.html
Frankly, I wouldn't like to do any of this, because it opens up too much security that I'd like to keep shut. The MySQL protocol isn't designed to be perfectly secure, so allowing remote clients to connect risks allowing attackers into your home computer.
Instead, I would recommend to run MySQL Server on a cloud server like Digital Ocean. Then you can access the same cloud server from either your home PC or from clients at school. See https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql
A small Digital Ocean instance that can run MySQL Server costs $5 or $10/month. Not so much compared to a single college textbook. See https://www.digitalocean.com/pricing/

Related

is there possibility to connect asp.net website hosted on a different server to a database on another server?

I know quite ok that is is not a good idea except for inevitable reasons. it is ideal to host database on the same server with the web applications. However my server couldn't log phpmyadmin using MySQL 5 despite all credentials correctly provided with no error except for the note that "Cookies must be enabled past this point." and i have set cookies to allow, add the website and others configuration and still not working. i have tried several browsers both on PC and mobile phones and its not working either. i tried to create database from several online remote source as FreeSQl, FreeDB, Somee etc, it works fine while tesing through visual studio locally on pc remotely but as soon as i host, it will not work as a result of connection issue which am aware of. i hope someone will help me out, possible provide me with link of where i can create and setup MySql database and the connection will work live on another server where i host my website or How to solve the Phpmyadmin issue. I will fine with it. I am available to answer questions so as to help me achieve my aim. Thanks
Not only is this possible, but is a common setup. You will often have some database server system - and it certainly not going to host the web site. The web site is VERY often hosted and placed on a different server.
In fact, some companies will adopt a hosting company for their web site, but it hits and connects to their database server that is on premises (or so called "on-prem"). In fact this approach is often used to allow say Android phones, and other services to consume data from the company database, but that company would NEVER think of opening up ports to outside connections. (they setup a secure connection between the web hosting system and their local network - often VPN, but it really don't matter. As such the company database server ONLY allows connections from the local network and then say a pre-defined IP address incoming from the web hosting.
So, you can adopt cloud hosted say SQL running on the Azure OS. (SQL Azure). And just like all instances of Azure? Well security can be several approaches. I mean a database hosted on Azure is RARE simply opened up to the wild internet to allow ANY one to connect. Heck, 16 years ago I tested opening up my home router to outside SQL connections. In less then 20 minutes, I began to see attempted logons to that SQl server.
There are bots that scan IP numbers + ports on the internet. So I began to see this:
Logon fail: sa, password="password"
Logon fail: sa, passowrd="123456"
etc. etc. etc.
So there is quote a few companies offering hosted database systems Azure, and AWS come to mind. However, they don't allow just any old one with a IP address to connect. In a lot of cases, security will be some fixed IP address (like for example the companies network or external fixed IP that their ISP provider gives them. While most consumer internet systems are not fixed IP addresses? Today even relative smaller business need and want workers to work remote. So they pay a few extra dollars per month (often only about $10, maybe $20) and now they have a fixed IP address. And from that they tend to setup and adopt a VPN based on that now fixed IP address.
The hosted SQL server? Well, it also will be setup to ONLY accept external incoming request from a known IP address - and thus those bots and IP scanners can't connect.
Now MOST low cost web hosting plans include SQL server or MySQL as part of the low cost hosting package. In that case, the connection from the web site to the database server is INTERNAL and such database systems do NOT allow or permit outside connections to the database server. So, when buying a book on Amazon.com, their web hosting system can easy connect to the database - but that is NOT a outside connection.
However, can you use that VERY low cost budget web hosting, and connect OUT to a outside database? yes, a lot of them allow this, and as noted, it not going to be a surprise that some database is being hosted say on Azure. And as noted, in this case, your web hosting software will thus connect to Azure in much the same way any other outside system connects. So while few web hosting systems allow OUTSIDE connections to the database included with such packages? Well, a lot of them certainly allow you to reach out - and hit other web sites, other web services (maybe a weather and temp display on your site????). So reaching out as a general rule is possible - reaching in? not so much!! about 10 years ago, quite a few web hosting providers - even low cost ones DID allow external ODBC connections to the database system. However, due to security issues - most providers don't allow this. I think even GoDaddy still allows this, but if you do ask for this ability, then the database server(s) you get are different then their regular ones - again they don't want to open up security issues and that can often open up holes to other customers databases hosted on that system. But, as noted, with the rise of SQL Azure and others? We are seeing a real comeback in hosting providers now offering external connections to database systems that are seutp to allow the hosted web sites to hit those databases.
So you have to check with who ever going to provide you with the web hosting, and find out if that web hosting allows "reaching out" to other web services, or reaching out to other database servers - as I noted - this is quite common now. it just a question then does the web hosting say support a VPN to reach out, or say reaching out on a particular port + fixed IP to some database server is the nitry grity details that will vary based on your needs, or what that ISP in fact allows.
So what and who and what ports are allowed to reach out? Well, that's going to be based on what your ISP and hosting plan for the web site allows - you have to check if they allow hosted web sites to "reach out" of their web hosting plans.

How can I connect a local MySQL database to the IBM Node-Red platform

I am using MySQL workbench on windows, which I want to connect to a Node-Red running on the IBM cloud. Since I don't run them on the same server the host 127.0.0.1 and port 3306 does not seem to work. What permissions should I give?
I'm going to make a LOT of assumptions here, because there really isn't enough information in your question.
First assumption, by "running on IBM" you mean that Node-RED is running on the IBM Cloud hosting service.
The short answer is you can not do what you want.
The longer version is that you probably could actually make this work but doing it is a REALLY bad idea.
Second assumption, you are doing this from home (even if you are doing it from a office location the same problems are likely to apply). This means you are connected to a local LAN using RFC 1918 address range (e.g. 192.168.0.x), this means you are behind a router that is performing NAT (Network Address Translation). This means you are going to need to set up portforwarding on the router so that when traffic arrives at the router it will send it on to your Windows machine. How you do this will depend on your router.
Next problem, your broadband probably doesn't have a static IP address which means it will change every time your connection drops. There are work arounds for this using things like Dynamic DNS. But that's too complicated to get into here.
Assuming you get all of that sorted out you still have the problem that you have now exposed your mysql database to the internet, so you need to make sure you have enabled all the right security measures to prevent people logging in and at best seeing all your data.
There are 2 much better solutions to this
Run Node-RED on the same machine or at least on the same local network as the database.
Use one of IBM Clouds hosted database solutions, these are a lot easier to connect to a IBM Cloud instance of Node-RED.
If you do not want to open ports to your network I recommend using a free MYSQL remote server
A simple website is https://remotemysql.com
Just take the screenshot of the credentials of your database after registration.
Keep in mind if your database is empty it will get deleted after some time.

How to connect a C # system with a MySQL database outside the LAN?

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.

Using an mySQL Database from another network

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.

Windows XP localhost as MySQL server alias

I'm on the road at the moment and just had a thought
I have a Windows XP Virtual Machine installed with Delphi and a local MySQL server set up with copies of the "live" databases back in the office.
I'd like to be able to use the local db in place of the "live" one if I'm offline.
At the moment in Delphi I have "local" connections set up, but these are only any use within Delphi. And often lead to issues if I forget to switch back to the live connection when I get back to the office.
Is there any way I can fool Windows into thinking that the local MySQL server is in fact the office server if it can't reach the office server? Can it spoof two server names?
You can edit the hosts file in c:\windows\system32\drivers\etc\hosts which will allow you to make any requests to server.fqdn go to 127.0.0.1
http://kb.simplywebhosting.com/idx/0/045/article/
e.g. a request to servername.domain.tld using MySQL connection strings will redirect to your local DB.
You will still need to remember to change this back when you get to the office...
(If you have delphi on the laptop though, why not create a simple service which edits the hosts file based upon whether the server is reachable or not.)