Connect Amazon EC2 to my Local MySQL Database - mysql

Is it possible to do the following?:
I have a local Mac running OS X Lion with a MySQL Server installed which runs different processes regularly and stores data into a local DB.
On the other hand I have an Amazon EC2 instance.
What I would like to do is to use the Amazon instance to perform certain cronjobs (using its own resources) but connecting to the data that is on my localhost (my computer) and performing basic SQL actions like updating the data, inserting, etc.
I don't know if this helps, but I have a static IP. Is there any way I can "open" my IP so the Amazon instance can recognize my home computer as a valid MySQL server?
Thanks for your help, any tip in the right direction will be much appreciated.

If your EC2 instance is connecting to your local db you'll need a static IP locally. Well not need... but if you don't have it anytime you reset your router or loose power etc your ip will change. You can look into Dynamic DNS as well for your local instance.
Your ISP will not block your port on your local instance. This would be a firewall inside your network that is preventing you from connecting to mysql or a configuration with mysql itself. Users can only connect to mysql from certain IP addresses.

You would have to open up the mysql port on your firewall if you are using one, have the mysql client installed on your EC2 instance, and make sure that the user that had proper grantable permissions.
That said why not run cron locally on the mac?

If you can login to your server via SSH then there's no need to open any other port and no static IP is required. You can use SSH port forwarding instead. From your local machine run:
ssh -C -R 5555:127.0.0.1:3306 <your-server-host>
Now you should be able to connect to your Mac's database running on localhost:3306 from the remote server at localhost:5555.

Related

MySQL Remote Connection (Replication)

I have the following topology.
One Ubuntu 16.04. Instance on the Amazon AWS where my global MySQL Server is running. I want to use this Server as a Slave (Multi-Source Replication) for many local Master (Windows Machines MySQL Server).
For Testing Reasons I`ve Managed to make this running on one local Machine (with three different MySQL Server Running).
But now I want to make this Replication work on the mentioned global Server with the local ones. But it fails on the attempt to connect from the EC2 ubuntu Instance to the local Windows MySQL Server.
When I try to connect from my EC2 Instance to the local Computer with MySQL running on Port 3307 it keep saying:
ERROR 2003 (HY000): Can't connect to MySQL server on (113)
The strange Part is, that I can PING the Local Computer but not telnet it.
Telnet just says:
telnet: Unable to connect to remote host: No route to host
I can access the Global (EC2 / Ubuntu MySQL Server) from the local Machine but not the other way around.
I`ve already made a new Rule for this Port on the Windows Firewall Settings.
But the Port 3307 on the IPv4 Address seems to be still Closed.
I have no clue what I am missing to get a Connection from the EC2 Instance to my local Computer via TCP.
Do I have to open the Port Specific on the Router?
I hope for your help.
Best Regards.
It seems like your local computer is not visible, as your incoming ports to your local pc are closed. It may be a problem with your router, or your internet service provider, which is not allowing you to open ports(the most common one).
The possible solutions are:
1.) If your ports are not open due to the router
Try forwarding required ports to your pc.
Try Switching off your NAT firewall that may be blocking ports.
Try switching off your windows or antivirus firewall if any.
2.) If your ports are blocked by your Internet service provider.
Try getting help from ISP
Switch to a static IP connection if on dynamic.
Use a VPN service that provides an unblocked port service to all IPs.(This one solved my problem when I was struck in this situation.)

Cannot connect to mySql from a lan network computer

I have a MySql Server 5.7 running as service on one computer of a LAN.
My application is installed and running fine on the same computer. I have 'Shared with everyone' set for the directory where my application is located. In the same directory I have put the libmysql.dll and the FDConnectionDefs.ini files.
My application is running fine on that computer. On the other computers on the LAN I created a link to the directory where my application is shared. When I try to run my application from these LAN systems they produce the error message
[FireDac][Phys][mySql] can't connect to mySql server 127.0.0.1 on port 3306... (10061).
All machines are running Windows 10 on 64 bit processors.
Here what i've tried to resolve the problem:
make sure that the user, password and host (%) are the same in mySql Profile and FDConnectionDefs.ini.
I've tried with different users even with root, i've tried to change host (%) to put the IP address of the computer trying to connect in the mySql profile.
I make sure that i have permissions to run my application and mySql and that the port 3306 is open in the Firewall/Kaspersky on each computer of the LAN. But always the same error message.
127.0.0.1 is a special IP address - the "loopback" address that is typically resolved for localhost on most systems. It is a private internal IP address that a computer can use to refer to itself. It has no meaning to other systems on a LAN since every computer will recognize 127.0.0.1 as meaning itself.
This means that when you are running the application on a remote system it will be trying to connect to a MySQL server running locally rather than on a server elsewhere.
You'll need to configure your FireDac components to connect to the actual LAN IP address that belongs to the system hosting the MySQL server. You will probably also need to make sure that your MySQL users are set up to authenticate from an IP other than localhost.

Fail to access remote server from another remote server

I have a remote server to which I need to connect to. Let's say the hostname is Remote01. From my local, I am connecting to it via a VPN (Juniper). I have another remote server in my intranet which is an RHEL server. I loginto this RHEL server (let's call it Remote02) and in the command line I type:
ping Remote01
This returns
ping unknown host Remote01
Do I need a VPN installed in Remote02 as well?
You would need to install the VPN client on Remote02 as well in order to reach Remote01.
Or, if you're comfortable changing the routing table and firewall of your own server/machine, you can changing the routing table on Remote02. For the network of Remote01, instead of going to the default gateway, point it to your local machine. On your local machine, modify the firewall to accept incoming packets from Remote02 to forward to to Remote01 via the existing VPN connection.
I would say the first solution is much simpler. But if for some reason, the VPN client is not available on Linux then you can try the second solution.

Custom Amazon EC2 instance and managing MySQL

so I've made an instance at amazon free web service, I've installed through putty mysql, php5, apache and so on on an ubuntu instance... But I can't for the life of me seem to find out how to manage the mysql on that instance. What am I missing? If I look in the Amazon RDS I can only manage for another instance, not for the one I have custom running...
As you have installed MySQL in the EC2 instance you can manage it via terminal.
Login to your instance using putty/ssh and connect to MySQL using below command
mysql --user=username --password=password
you need to install MySQL client if you installed on only MySQL Server.
If I look in the Amazon RDS I can only manage for another instance, not for the one I have custom running...
Yes, RDS is a service where Amazon manages the entire database box for you. The AWS Console manages (paid) RDS instances, not databases in general.
But I can't for the life of me seem to find out how to manage the mysql on that instance.
The "normal" way. Amazon doesn't come with CPanel or other GUI administration tools. Mainly because experts don't need them.
If you want to manage your MySQL graphically, install something like PHPMySQLAdmin or the like.
Note: never open the MySQL port to the internet. If you need to connect to MySQL, use "port forwarding" in Putty to forward port 3306 to the remote box port 3306. Then you can run a MySQL GUI client locally.

Connect SSH MySQL server from Windows

I have installed MySQL on Ubuntu using SSH and would like to connect phpMyAdmin installed on a Windows machine.
I tried to add a server like standard server, but I can not log in to MySQL server using SSH.
Does phpMyAdmin support to connect a remote server using SSH? If yes, how can I configure a private key for phpMyAdmin or do I need a SSH client for this?
I think there's a bit of misunderstanding that might be hindering you sorting this out.
SSH is the Secure Shell protocol, which allows a user to remotely access the command line of a server. You can access MySQL via SSH by using SSH to start a command line session on the server and using the mysql command line client as if you were at the machine directly.
phpMyAdmin can connect to a local MySQL instance (where MySQL and your webserver run on the same machine) or connect to another machine through the network (where MySQL is running on one machine and your webserver is running on another -- the connection in this case is via the the port used by MySQL itself, 3306). In either case, you can access phpMyAdmin itself from any browser on the network; it just appears as any web page. The communication between MySQL and phpMyAdmin can be encrypted (via SSL) if you wish, but still happens via MySQL communication and not over SSH. At no point is SSH used for the communication from the web server to the MySQL server.
So in your case, since you wish to install phpMyAdmin on the Windows box, you'd simply edit your config.inc.php to connect to the IP address or hostname of the Ubuntu server with the $cfg['Servers'][$i]['host'] = 'hostname'; directive, using the actual hostname instead. You'd then access phpMyAdmin from anywhere on the network by using the hostname or IP address of the Windows machine.
If, instead, you wish to install phpMyAdmin on to the Ubuntu machine, you could use the host name 'localhost' in config.inc.php and then access phpMyAdmin from the Windows machine (or any other machine) using the Ubuntu IP address/host name in your web browser.
It all depends which machine you wish to be the web server. phpMyAdmin runs under IIS or Apache runs under Windows, but Ubuntu makes installing all the programs easy through the package manager, so that's what I generally do in this situation.
Hope that helps clear it up a bit.