MySQL foreign data wrapper: use SSH parameters for SSL connection? - mysql

this might be a very rare usecase, but what I'm trying to do is:
Connect to a MySQL-Databse (of my website) from a PostgreSQL Database to create a foreign table that gets the website-user information from the MySQL Database.
So what I did so far is installed the MySQL foreign data wrapper (fdw) for PostgreSQL and tried setting up the foreign server. The problem is, the webhost only allows SSH access to the database while the mysql_fdw only accepts additional SSL parameters:
{ "ssl_key", ForeignServerRelationId },
{ "ssl_cert", ForeignServerRelationId },
{ "ssl_ca", ForeignServerRelationId },
{ "ssl_capath", ForeignServerRelationId },
{ "ssl_cipher", ForeignServerRelationId }
So my question is, can I somehow use my SSH login credentials (SSH user/pw or key pair) to generate the necessary SSL parameters?
Does anyone have a clue on how to achieve this?
Thanks and kind regards,
Michael

You almost certainly aren't accessing MySQL via ssh. What you are doing is accessing the server it is on via ssh and then connecting to MySQL. You might be doing this just by running the mysql command-line client or by forwarding a port to your local machine.
So - if you want to connect to MySQL from your PostgreSQL server it will need to be accessible from the internet. You should open up just PostgreSQL's IP address for MySQL's port on your firewall. Then, your GRANT statements on MySQL can the user login to that remote hostname too. Have a separate user just for this remote connection.
It might also be possible to require a known client certificate from the PostgreSQL connection. That will further secure access.
Now - it might be that you are on a service that doesn't allow remote MySQL access at all. In which case, you will either need to set up a permanent ssh tunnel (fiddly, can cause problems when intermittently connection drops) or push data from the mysql end.

Related

MySQL Domo AWS RDS Connector

I'm having issues connecting Domo to a MySQL database hosted with AWS RDS. Whenever I try to authenticate I get this error:
"Failed to authenticate. Verify the credentials and try again. Domo is ready, but the credentials you entered are invalid. Verify your account credentials and try again. Error setting up SQL connection. Could not create connection to database server. Attempted reconnect 3 times. Giving up."
Its not security group settings. Someone suggested on this post:
https://dojo.domo.com/t5/Data-Sources-and-Connectors/MySQL-connector-issues/td-p/15462
that I should enable SSL in AWS database but I'm not sure how to do that.
I'll assume you're using the MySQL connector, not the MySQL SSH connector.
It sounds like you need to whitelist Domo's IP addresses within your AWS RDS's security groups.
Aside from that, make sure you're populating the credentials in Domo with the right pieces of information. Hostname should be the server's public IP address.
This connector follows the same general process as described in AWS's documentation here, with the exception that steps 5 and 6 are optional since SSH is not required for this connector.

Trying to connect to a mySQL db on Amazon AWS using mySQL Workbench

I just opened an account on Amazon AWS. In this account, I created a mysql database instance, that I am now trying to connect to on my home computer use mySQL Workbench. I have entered the database endpoint (as listed in my account) and added the user name I set up for the master username for the database. When I hit "test connection" (using standard TCP/IP connection) however, I get a "Failed to connect..." message. I have a feeling that the problem may be that I need to use SSL and/or SSH. But I am a neophyte here, and I don't know how to properly set this up or configure mySQL Workbench with this. I am seeking assistance
You need to allow your mysql server to the user my user policy.
You can allow your Public IP address.
Please refer below case:
Cannot ping AWS EC2 instance
I think there that my database instance was misconfigured somehow, though not as JERRY suggests. I created a new MySQL DB instance and was able to connect to that without needing any other special configuration changes. So I am now using the new instance, and have deleted the old one. I wish I could provide more insight into what the problem with the first DB was, but the insight I have is (as I said) after I created the 2nd DB instance, no other configuration was necessary

How to know where my MySQL database is being hosted and how can I access it?

I have the following information to a SQL database
Server : MyUserName.mysql.db
User : MyUserName
Password : MyPassWord
I am a little noob in this context, so I have some questions:
How to know where is hosted my database? Is it in mysql domain? (Isn't that the type of database?)
How can I access it and visualize it?
To begin with, you need a CLIENT to be able to access your database. For MySQL, you can use either Workbench or MySQL CLIENT (the last giving you command-line level access).
Second, and according to your information, the server is MyUserName.mysql.db so if you try to PING that server you should get some response.
Third, MySQL has a default port number so you need to configure your client to access that server though that port (if I'm not mistaking, 3306).
You will also need access credentials to your database.
Your DB administrator should be able to provide all the information you need.
Contact your database administrator.
If you're trying to acess/visualize sql server database on your local computer install ssms to connect to your local database , similarly you can access any other database through ssms.

Alternative to port 5432 for connecting two PostgreSQL Databases?

We need to query and pull data from our client's remote PostgreSQL database and ultimately import it into a table in our MySQL database. Due to security concerns, our client is unwilling to open access via the default port 5432 so we can do this. We have considered possible setting up a PostgreSQL database on our end and trying to connect with that, but we don't know if that will give us any more flexibility.
The question is, is there an alternative port other than 5432 that we can have our client open up so we can access?
Configure PostgreSQL server to accept connections from a specific IP + authentication, without changing default port. This normally should be done even for local connections.
Configure router/firewall to do port forwarding (i.e. firewall:port9999 --> postgresql_server_ip:port5432) + add source_ip as another layer of "security"

Can't Connect to MySQL instance Remotely that is running on EC2 Instance (Not RDS)

I have seen a lot of posts that claim they are running an RDS instance of MySql in which they cannot connect to, but I am not running RDS.
I used my EC2 insance to host my wordpress blog which was installed using the Web Platform Installer.
This setup the wordpress schema and data that I needed and I have been running it for a couple years.
I want to be able to access this database remotely instead of only logging into my server.
I have checked and have the following users
root
wpadmin
I have also verified that the port specified in the mysql config is the standard 3306 and I have setup an Inbound Firewall rule to allow 3306 through.
When I try to connect from MySql Workbench, I get the following error message:
Number 3 Is particularly one that I do not know how to check, but I do know that MySql is running and that it is running on 3306. Additionally, I know I am using the correct password.
When I try to connect, the prompt looks like this. Do I need to do something to grant Mysql user permissions or anything?
Based on your GRANT information, you have at least the problem of root user only having access privileges from localhost. You would need to create a root#% user (or a more specific host/IP instead of % if you have a reliable address). That would allow external access so long as your EC2 security group also allow access on port 3306 (either globally or to a more restrictive IP address or IP range).
Of course the security implication here is that you are opening up access to MySQL that you might not want to make more accessbile to potential attackers. For this reason, I would recommend you access your DB via SSH tunnel, which is supported by MySQL workbench. This will in essence allow you to shell into the host your your access key and then access as root#localhost.