can't access fortrabbit mysql db through terminal (ssh) - mysql

I can't access mysql through terminal on fortrabbit. I follow all steps but it is rejecting my password. However I can regullary login through ssh and edit my application. Anyone had that issue ? Thanks.

I have solved this in the past using a SSH tunnel. You open an SSH tunnel to the server, and then you connect to the MySQL server there from the endpoint of that tunnel. As such, to MySQL you appear to be connecting locally.
From the terminal:
First you need to open the tunnel, you can do it like this:
ssh -N -L8889:127.0.0.1:3306 username#your.fortrabbit.domain.com &
This opens port 8889, then opens a tunnel to your.fortrabbit.domain.com, then forwards that local port through the tunnel to the IP 127.0.0.1 and port 3306 relative to the server at your.fortrabbit.domain.com.
The options in more detail:
-N: Do not execute a remote command.
-L: Specifies the ports (local and remote).
8889: Your local port that is being forwarded.
127.0.0.1: the remote IP to which you're forwarding, relative to the server which ssh is connecting to
3306: the remote port to which you're forwarding.
username#your.fortrabbit.domain.com: Your username and domain with fortrabbit.
Now you're ready to open the connection. In the same terminal, use the following command:
mysql -h 127.0.0.1 -P 8889 -u mysql-username -p
port 8889 is now being forwarded to the port and IP of your MySQL server on the fortrabbit side, so just replace mysql-username with your username on the mysql server, and you're connected!
From a GUI:
You mentioned in your comments that you're using Ubuntu, so install MySQL Workbench from the Software Centre or here, create a New Connection and select the connection type as "Standard TCP/IP over SSH".
You will need to configure the following:
SSH Hostname: the hostname or IP of your ssh account with fortrabbit
SSH Username: your username with them
SSH Password: your password with them
SSH Keyfile: If you use keys for authentication, select the private one here.
MySQL Hostname: 127.0.0.1 (because it's local to the endpoint of your tunnel.
MySQL Server Port: normally "3306".
Username: The username for the DB
Password: The password for the DB
Default Schema: Whatever should be the default schema for this DB (can be left blank).
That should then connect from wherever you are!

Related

Why can I connect to mysql through ssh -> mysql, but cannot connect through a ssh tunnel, address is bound to localhost(bind-address 127.0.0.1)?

I can connect to the server by ssh (ssh #ssh_user###ssh_host#) and then use mysql -u#db_user# -p#db_password#. Then I can use the mysql command line as usual, but I am trying to setup DBeaver so I have a client interface for it. Is it impossible to do when the bind-address is set to localhost?
SSH tunnel settings
host: #ssh_host#
port: 22
user: #ssh_user#
auth: (key)
SSH tunnel itself works, I tried it with ssh -L 23:#ssh_host#:22 #ssh_user###ssh_host#

Cannot connect to Database MySQL from workbench

I am try to using MySQL Workbench but its showing error "Cannot connect to database".Neither it taking it localhost or my Endpoint of AWS RDS as DNS in host in workbench.
"I am using Xampp for mysql server running on port number 3306 "
Error :
Cannot connect to DataBase Server
Your connection attemp to failed for user 'root' from host to server at localhost:NULL;
can't open named pipe to host:pipe:MySQL (2)
Please:
1.Check that mysql is running on server localhost.
2.Check that mysql is running on port NULL (note 3306 is the default,but this can be changed)
3.Check the root has rights to connect to localhost from your address .
4.Make sure you are both providing a password if nedded and using the correct password for localhost connecting from the host address you are connecting from.
If you want to test the connection to MySql, Use Heidi (i recommend it). If it didn"t work, check if your DataBase server is running in port 3306 by taping:
netstat -atp tcp | grep -i "listen".
You can also change listenning port in /xampp/mysql/bin/my.ini:
my.ini:
Password = your_password
port = 3306 ---> 3307
socket = "/ xampp / mysql / mysql.sock"``
Looks like you have no port configured. Check your connection settings that you have a port set.

Remote Access MySQL connection error

I am trying to remotely connect to a MySQL server. I have followed advice from (1) and setup a user on the ip address I will be remotely accessing from.
user$ mysql -u TestUser -p -h 129.169.66.149
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '129.169.66.149' (60)
I have checked and the port (default, 3306) is correct and the ip address is correct. MySQL is also running.
From a remote computer, I can successfully ping the server
ping 129.169.66.149
64 bytes from 129.169.66.149: icmp_seq=48 ttl=63 time=1.010 ms
But when I use Telnet:
TELNET 129.169.66.149
Trying 129.169.66.149...
telnet: connect to address 129.169.66.149: Operation timed out
telnet: Unable to connect to remote host
Can anyone advise? Is this a firewall issue?
(1) - https://superuser.com/questions/826896/access-wordpress-mysql-database-remotely
First try to check TCP connection issue, using netcat and telnet : on the mysql server, stop mysqld (to release port 3306) and run netcat on listen mode :
nc -l -p 3306
Now, netcat is listening port 3306 (like mysqld does when it's running) and will show what happen on that port (incoming connections, what's in the wire...).
On your remote computer (mysql client), try to connect to the mysql server host :
telnet 129.169.66.149 3306
or :
nc 129.169.66.149 3306
If this is not working, this is not a mysql server configuration issue but a network issue, and you must check your router firewall rules.
Otherwise, your problem comes from mysql server settings. Check your mysql configuration file for bind-address, and remove them to make mysqld accept clients from any IP address.
The 3306 port on the 129.169.66.149 server is closed you'll have to open this port
Use this reference as a guide http://www.cyberciti.biz/faq/linux-unix-open-ports/

Vagrant: open mysql connection to host

I'd like to use MySql Workbench to browse my database in Vagrant from host machine.
So far I just commented the line bind-address = 127.0.0.1 in my.cnf and all was ok, but recently I connected to a new wi-fi and things seemed to change, I had to change guest ip address from 192.168.0.200 to 192.168.1.200 and I can't open mysql connection from host.
I tryed also to add bind-address = 10.0.2.2 guessing (not sure) this was my host ip but still the same.
What do I need to do?
Thank you
Define a static ip for your box like in this example:
Vagrant.configure("2") do |config|
config.vm.network "private_network", ip: "10.0.0.6"
In Mysql Workbench create a new connection over SSH:
Connection Method: Standard TCP/IP over SSH
SSH Hostname: 10.0.0.6 (like above)
SSH Username: vagrant
SSH password: vagrant
MySQL Hostname: 127.0.0.1
MySQL Username: root
MySQL Password: root
SSH Host Key identification:
Instead of a password you can use the box specific Private Key. You can get the path by executing vagrant ssh-config.

why is mySQL connecting at any/all ports

I'm running Linux Mint and trying to connect to mySQL this way
mysql --port=3306 -u root -p
Then it prompts me for my password. This is all fine. Why is it that when I type something like this it still works....
mysql --port=1234 -u root -p
Should that not fail since there is no mySQL server running on port 1234?
The reason I am asking this is because I want to create a SSH tunnel to connect to a database on another server. Let's say the SSH tunnel will forward all my traffic from localhost:3308 to myremoteserver:3306. Since my local mySQL server is accepting my connections on all ports, I cannot actually connect to port 3308 and hit the remote server. I am still hitting my local server....
Even if my SSH tunnel options might have been wrong, I was wondering if anyone knew why I can connect to port 1234 and it still hit my local mySQL server running on 3306?
IIRC mysql connects you to a Unix socket if you are connecting to localhost. Since it does not connect you via TCP in this case, there is no port involved and the port number you give does not matter.
Edit: Not sure if this is true on all systems, but If I use 127.0.0.1 or the hostname instead of localhost, mysql connects via TCP and the port number does matter - I can connect with the correct port number only.
To force a TCP connection use --protocol=TCP.
Example:
First the SSH tunnel
ssh -L 4000:localhost:3306 server.ch
and then connect to the remote mysql server with
mysql -h localhost --port=4000 --protocol=TCP -u root -p
It will ask you for your password before it tries to connect. If you enter your password (or anything else for that matter), and let it proceed, it will respond with something like:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock'
#titanoboa, thx for this! I was having the same issue. Just to add you can actually force TCP connection even for localhost using the following
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
protocol = TCP
Cheers