SSH Connection to MySQL DB - mysql

I am a layman and I am not sure if I understand correctly how does an SSH connection to a MySQL DB work.
Shown below you find a screenshot of a common GUI used to set-up the connection in object.
I understand that I need to insert the MySQL Server IP, the port, my user and password in order to connect to the SQL DB. But I do not fully understand why I need to provide a SSH Server IP address, user and password.
If I am able to connect to a MySQL Server using a direct SSH connection, why would I need to mention an SSH Server (another machine)?
Does the SSH Server act as an intermediary? If so why and how? Could you help me understand?
Thank you in advance.

Related

failed to connect to Mysql at [AWS RDS ADDRESS] unable to connect to localhost

Our company has a database server on AWS which other the employees can connect to it with MySQL, but when I tried, I got this error message, how can I solve it?
I tried to reconfigure MySQL server but it didn't work. also I double checked username, password, url and port.
To connect to an RDS MySQL instance from MySQL WOrkbench on your dev machine, check a few things.
First, get the full endpoint to the database from AWS Management console.
Ensure the database is publicly accessable.
Also, make sure that you set up your inbound rules correctly.
Once you do these things, you can use MySQL Workbench to connect.
In the hostname field, make sure you put in the hostname you copied from AWS Management console. Do not put in extra information such as:
dbc:mysql://forxxxxxxxxxxxxx.us-west-2.rds.amazonaws.com
make sure it is:
forxxxxxxxxxxxxx.us-west-2.rds.amazonaws.com
THen specify the user name and password and MySQL Workbench will connect:

Can't connect remotely to MySQL cPanel database

I can't connect remotely from Nodejs to a MySQL database from a domain. I've searched a lot, my ip is listed in the host list, and I've also checked the MySQL variables and the bind-address is set to *.
And, also, does anyone know why when I try to add a new host for remote mysql connections it says that the % wildcard is not allowed?
With another domain it works just fine.
Please help me figure it out.
Thanks!
You need to check if the port is open from remote by using MySQL workbench or other clients. You can also use telnet in the command line:
telnet {database ip} 3306
If you got a timeout, It seems there is a Firewall or Mysql config not listening remote IPs so call your ISP or hosting provider and ask them for open access.
But if you got "access denied" message or telnet connection was successful, we have something wrong in MySQL user privilege.

How can I connect a Jupyter Notebook to a remote MySQL DB using Peewee?

I am trying Peewee to connect and retrieve data from a MySQL remote database, but I get the following error:
InternalError: (1130, "Host 'x.x.x.x' is not allowed to connect to this MariaDB server")
Could you help me?
"retrieve data from a MySQL remote database"
"Host is not allowed to connect to this MariaDB server"
Seem to point on a simple problem:
You're not allowed to connect on the DB from "outside".
By default, MySql / MariaDB are only listening on the "inside" of the server, from MariaDb doc :
MariaDB packages bind MariaDB to 127.0.0.1 (the loopback IP address) by default as a security measure using the bind-address configuration directive.
This mean apart for an application that run on the same machine (accessing 127.0.0.1 or localhost), you'll not be able to connect.
Solutions:
SSH tunnelling
This is probably the safest way to allow a connexion on a remote DB.
SSH is a protocol that allow you to connect to a server. It's mainly used on unix server to manage them, but can do a lot more.
How to use it in your case?
if you can connect with SSH to your DB server, then running this simple command on your notebook the will do the trick:
ssh -L 3306:localhost:3306 user#x.x.x.x
Lets explain a bit: first, your run SSH, then, you tell him to enable a port forwarding from your 3306 port to the localhost:3306 port of the server you connect through user#IP.
With this command running, every query from your local machine:3306 will by send to your MariaDB:3306 server, allowing you to use it as if you where on the server.
Allowing a remote-access user
This one is way more dangerous than the previous one. You'll need to take your time and think about every outcome it mean.
As already said, you're not allowed to connect from outside, ssh let you be "inside", but if you know what you do, you can just remove the security.
The point is:
to make an account that'll be able to login from a remote IP,
allow MariaDB to listen on external requests,
and at least, secure other account to disable remote connection.
[I'm not putting the how-to now, if you really need it, I'll update this answer]

Changing SSH Password which is routing through mysql

I have mysql root username and password with me and i am on centos server. I know how to login through putty to the mysql panel.
I am in. we are also connecting the mysql through Navicat and it accepts the SSH connection to the mysql server even we do provide the username / password because the server is not directly linked.
So, what is the possibility that i can change the Password of the SSH which is doing the mysql connectivity through navicat.
how can i use the command console panel to change the SSH to change it
Please do not vote for negative as if the question is not clear, ask me before downvoting
Regards
So, Here is the Solution.
When i was logging into putty, i was doing the ssh using my username and password, the same credentials i used in navicat and bang it worked, so there was no need to change the credentials, i already got it connected to my database, sory about the confusion, hopefully one should never encounter this issue, for me it was hard to debug as i was very new to centos operating system

Login mysql via mysql-workbench or mysql-query-browser with phpmyadmin access only

I have access to the database only through phpmyamdin. What can I do to log in via mysql-query-browser or mysql-workbench? I enter my password, username and host to mysql-workbench but there is no connection.
Thank you.
If you do not get an error any message, it sounds like there may be a firewall blocking the request on port 3306. You may also need to ask for privileges for the user/pwd that you are logging into from the host machine you are logging into.
It's possible that mysql is only listening in localhost, so you can't access it with any program that's not on the same machine as the mysql server (and phpmyadmin can access it because it's on the same server).