Connect to remote MySQL database on ec2 Ubuntu machine - macos

I have seen a few related questions on SO, but none have helped me. I setup a MySQL database on an Ubuntu machine on EC2. I am trying to connect to it from within R, using e..g ,
con <- dbConnect(MySQL(), username = user, dbname = db, host = host, password = password)
where the username and password are those for the remote database, and the host is the ec2 address (something like ec2-54-456-161-6.us-west-2.compute.amazonaws.com [not a real one])
Any thoughts on how to do this?
To log in to the Ubuntu machine the database is installed on from the shell on my machine I have to use the key pem file. Does this key have to be provided to authenticate? If so, how?

Make sure the MySQL instance listens on the network, even if you're on the same machine. In /etc/mysql/my.cnf, change this:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
This should be in a number of MySQL tutorials and is not EC2 specific.
You want to make sure that you can connect to the DB from the server itself. Once that is taken care of, try the remote access. If a port ends up being blocked, you can also got the route of an ssh tunnel -- which again is described in a number of tutorials.

The problem in my case was that I just need to add a new rule to the security group to allow remote connections on port 3306. See below screenshot of the rule added (the bottom line)
That was all that was needed.

Related

How to connect to an Oracle Database running on Amazon AWS EC2?

I have an Oracle Database instance running in Amazon AWS EC2 service. (it is not RDS Relational Database Services).
How can I configure my Oracle SQl Developer to to access this remote databse in AWS EC2?
By checking AWS documentation I found only references to connect to Oracle databse running in RDS services.
I apreciate your help.
Thanks
In AWS, edit the Security Group for your instance to add a rule (if one doesn't already exist).
Inbound
Type = SSH
Protocol = TCP
Port Range = 22
Source = "My IP", or "Custom" (as you wish)
In SQL Developer, open View -> SSH.
Right-click "SSH Hosts", New SSH Host.
Name = whatever you like
Host = your server's IPv4 Public IP address
Port = 22 (default)
Username = root or ec2-user, whichever is appropriate for the linux AMI you used
Use key file = tick this and select your key file for your instance
Add a Local Port Forward = tick this and accept the defaults (localhost, port 1521)
Edit the properties of your SQL Developer Database Connection
Connection Type = SSH
Port Forward = the name of the SSH Host you created earlier
SID / Service name = whatever SID or Service name you need
If you want to add another layer of security. SSH or DMZ + Load Balancing is the way to go. If not Make sure the following are all open for the IP. firewall, VPC Network, AWS inbound outbound rules.

How to connect to Neo4j server running on Windows machine from Ubuntu machine?

I am using Neo4j graph database. Its running on Windows PC at url: http://localhost:7474/browser/. Now I want to get access to this server from machine running Ubuntu OS, so that I can access Neo4j browser and can use it for development purpose as well.
Here is what you need to do: -
Uncomment "org.neo4j.server.webserver.address" and provide a valid IP-Address on which you want to bind your neo4j http service at port 7474 in your neo4j-server.properties and restart your neo4j server.
Try accessing you Neo4j server on local machine by entering URL - http://:7474/ (Do not use localhost).
Switch off all firewalls and ensure :7474 is accessible from any remote machine. You may test it with Telnet too.
In case all the above works then you are done and your Neo4j server is accessible from remote machine.
I think you'll need to configure your conf/neo4j-server.properties file to allow access from non-localhost addresses. Here's the relevant part of my file:
# Let the webserver only listen on the specified IP. Default is localhost (only
# accept local connections). Uncomment to allow any connection. Please see the
# security section in the neo4j manual before modifying this.
#org.neo4j.server.webserver.address=0.0.0.0

Vagrant: Why forward database ports?

I'm a vagrant newbie trying to configure his first instance. But wherever I look on Vagrantfiles configuring PostgreSQL they're always using port forwarding to the host.
config.vm.network :forwarded_port, host: 5432, guest: 5432
What is the point of forwarding database's port to the host?
Shouldn't the database be operating inside the box?
Or is it just a practice to have better data persistance?
And even if this is desired workflow and everything's forwarded then what is the point of installing the database inside the box after all?
This is mainly so that you can use Graphical Database SQL tools to query your Postgres database from your host machine. Since vagrant is used mainly by programmers and they need to frequently check the database for testing/debugging, this is in place. IDEs like IntelliJ and Eclipse have tools that you use to query databases and they would run on the host machine and thus would need to have access to the database port.
If you don't need to query your database from your host machine and it is only accessed by the guest VM, then you don't need this set.
Shouldn't the database be operating inside the box?
Yes.
Or is it just a practice to have better data persistence?
There is no relation between port forwarding and data persistence.
And even if this is desired workflow and everything's forwarded then what is the point of installing the database inside the box after all?
What is the point of forwarding database's port to the host?
There is no need to always forward port. Port forwarding is only needed when you want to access that port from host machine, e.g. using graphical tools as pointed by blownie55's answer. If you don't need to access the port from host then there is no need to forward it.
And this is true for all kind of port forwarding, not only for database port.
As a side note, there are other ways to access resource inside guest from host, e.g. configuring a private network.

Connect to an ejabberd server from another machine

I have ejabberd installed on my windows 7 machine .I created users using the web admin and clients are connecting fine.(I am using psi). I want for the users on other machines to be able to connect and even users with android clients.
I have modified the hosts file in
C:\Windows\System32\drivers\etc\hosts
like this:
127.0.0.1 domain.tz
192.168.0.161 domain.tz
192.168.0.161 is the ip address of the machine the server is installed on.I can ping it from other machines but when i try to connect a user with let say usr: user1#domain.tz pwd: passwrd it says the server can't be reached. What do I need to do to let clients connect successfuly to my ejabberd server?I apologize if this is basic but this is my first trial on xmpp server administration.
It was a problem with my own understanding with DNS .The domain name you set up when you set up your xmpp server should be an already existing ACCESSIBLE address on the network. I found the name of my pc simply by running the famous
ipconfig/all
on windows and used the host name value as my domain while setting up ejabberd.It usually even finds it by default.
NOTE: To reconfigure ejabberd ,I uninstalled it and deleted everything in the
C:\Users\myUserName\AppData\Roaming\ejabberd.
If i didn't do so ,the last settings of the server are not deleted and you can't create your new admin account.These are my findings on ejabberd so far and I hope it helps somebody some day.

What is the oracle database 12c IP Address

I just Installed Oracle Database 12c. At the end of the installation it gave me Information about my connection. SID, IP, etc. I restarted the computer run all these services (some of them already running):
OracleJobSchedulerORCL
OracleOraDB12Home1MTSRecoveryService
OracleOraDB12Home1TNSListener
OracleRemExecServiceV2
OracleServiceORCL
OracleVssWriterORCL
But I think I forgot the IP and port of my database since I tried to access the database using a webbrowser and it doesn't work (I tried https://10.10.10.10:5500/em). I don't know If the problem is really the IP:Port that I may have forgotten or if I forgot to run service. I am pretty sure the IP address look like https://10.10.x.x:xxxx/em but I don't I am not certain. Is there a way to recover the IP address and port of the database?
EDIT: I've installed it on Windows 8 x64 JP. with
In Environment Variable
with ORACLE_HOSTNAME = 10.10.10.10
ORACLE_UNQNAME = orcl
And in the host file (in System32/Drivers/etc/)
127.0.0.1 localhost
10.10.10.10 wopr.orcl wopr
Per documentation, format for accessing enterprise manager in your browser
http://hostname:portnumber/em
Once you sure that default port number is kept as default HTTP port number is 5500 then you can get your system hostname. Port numbers are recorded in $ORACLE_HOME/install/portlist.ini file.
If running windows then just run the command hostname which will give you the hostname of your machine. Then run like
http://My_hostname:5500/em
Or use the command ipconfig to see your IPV4 address and use that address
http://X.X.X.X:5500/em
Or you as well use localhost
http://localhost:5500/em
or 127.0.0.1 (loop back address) like
http://127.0.0.1:5500/em
See here for more information
Well, if you installed it on your local machine, you can always access it using localhost, so try https://localhost:5500/em.
The default port number for Enterprise Manager is indeed 5500.

Resources