Connect to a live database with MySQL Workbench - mysql

I've a question to the mySQL Workbench.
I want to connect to the mysql DB at the domain aaa.com. I write at the connection options these dates:
Hostname: www.aaa.com
Port: Which port do i have to write in?
Username: Username of the DB (which is 100% correct)
Password: Password of the DB (which is 100% correct)
Default Schema: Name of the DB (which is 100% correct)
If I click connect there is following error:
"Access denied"

Also you can ssh tunnel:
Create a new connection, select Standard TCP/IP over SSH.
For SSH host name enter your domain aaa.com (the domain you would SSH to).
For SSH username enter your SSH username, so if if you ssh test_user#aaa.com your user is test_user.
Store your SSH password or key files, which ever you use.
The Mysql hostname should be 127.0.0.1 if the mysql server is on the server you are SSH'ing to, else the IP or host name of you Mysql server.
Mysql server user - your mysqsl user.
And your Mysql server password.
This way your database isn't externally acceptable, meaning no one can trying to access it from outside your server on port 3306, but you still have access it through Workbench

Contact your web hosting company to make sure they allow remote connections first. It's disabled by some hosts. Default port will be 3306.

Generally, for security reasons, the incoming connections from external domains will be disabled. Contact your host if that is allowed.
By the way, the default port of MySQL is 3306.
If you have root access to phpMyAdmin, you can see if the port is opened using this tutorial: Install MySQL and enable remote access.

Related

Connecting to Remote MySQL DB over ssh with workbench

I'm trying to connect to a remote DB with MySQL Workbench over SSH. The remote DB I'm trying to connect to has firewall which is private key protected (I have coverted this to OPEN SHH). I keep getting an error when I try to connect, I'm just a little confused on what is the information of the DB I should be using. I consistently see people use localhost and the DB changed intermittadely at the same point in different questions. My set up is currently that I have to connect to the server of the firewall(check) now there are multiple VMs running I wish to connect to e.g. 192.1.91.0. I have also a port set up to this on putty( I don't know if this is relevant) on localhost 5000. When I try to connect using 192.1.91.0 port 3306 or localhost 5000. I get the same error. Can anyone help. Attached is an image of the information I put into workbench
I think there are a few misunderstandings here. A firewall is not protected by a keypair. An SSH connection is. The firewall only filters network traffic using specific rules (e.g. only let it pass for enabled network ports). When you use an SSH connection you have to use the MySQL address as seen from the remote SSH connection end. That means if the MySQL server runs on the same machine as the SSH server (which is what you connect to when you use an SSH tunnel) then the address is localhost (or the IPv4/IPv6 loopback address). See my video about connection creation and troubleshooting on Youtube for more details.
To connect workbench with a private database you will need a 'jump host' also called 'bastion host' which can be any EC2 instance in a public subne in same VPC as database.
Follow Below Steps:
Open the security group attached to the database, and add new rule as below:-
Type:MYSQL/Aurora, Protocol:TCP, PortRange:3306,
Source:securitygroupofEC2 (you can all security group by entering
'sg-')
Open the security group attached to the EC2, and make port 22 is open. If not, add a new rule as below:-
Type:SSH, Protocol:TCP, PortRange:22, Source:MY IP
Open Workbench, Click New connection
- Standard TCP/IP over SSH
- SSH Hostname : < your EC2 Public IP > #34.3.3.1
- SSH Username : < your username > #common ones are : ubuntu, ec2-user, admin
- SSH KeyFile: < attach your EC2 .pem file>
- MYSQL Hostname: <database endpoint name> #mydb.tbgvsblc6.eu-west-1.rds.amazonaws.com
- MYSQL Port: 3306
- Username : <database username>
- Password: <database password>
Click 'test connection' and boom done!!
If the MySQL Server is configured to accept remote connections, you can use the servers IP address, but then you don't need to connect over ssh. Once you choose connect over ssh, the workbench creates a portforwarding using the ssh credentials to the specified server. So you have to use localhost as MySQL hostname. Due to the portforwarding, the request will be forwarded to your remote machine. In short: As far as I understand your question, you have to use localhost.

How to connect to MySQL Workbench?

I've bought a server from CloudAtCost.com and all the information it gives me about my server is Server ID, IP Address, Netmask, and Gateway. I can SSH in just fine, but I can't get MySQL Workbench to connect to it. I've tried both Standard (TCP/IP) and Standard TCP/IP Over SSH.
I figured it out. I was using "user" as my username when I needed to use "root".
MySQL server needs to be running.
Network connections need to be enabled.
You need to know what port MySQL is running on (default is 3306).
If reverse DNS lookup has not been disabled, MySQL has to be able to resolve IP address to hostname.
MySQL User has to be created and assigned a password, a username and host, host is either the specific host connecting or (less secure) a '%' wildcard for host. If DNS lookups are disabled, host will be an IP address.
Connections to the MySQL port (by default it's 3306) may be "blocked" by firewall...
There are a lot of possible reasons.
When we can't connect, there's usually a MySQL error message that indicates the kind of problem encountered.
But, my preference would be to only allow IP connections from 127.0.0.1. (We always turn off reverse dns lookups on our MySQL servers.)
I'd use ssh port forwarding (tunneling). Choose a port to use on your local machine, e.g. 13306, and configure SSH to "forward" connections to that port through the ssh connection...
You can configure that in the .ssh/config for the specific remote server, e.g.
Host remoteserver
LocalForward 13306 localhost:3306
You'd need to first ssh to the remoteserver, and keep that session open.
Then on your local machine, MySQL Workbench would connect to localhost port 13306. On the MySQL server side, that will be seen as coming from IP address 127.0.0.1,
Obviously, you'd need to have a user created, e.g.
GRANT USAGE ON *.* TO myusername#'127.0.0.1' IDENTIFIED BY 'mypassword'
And grant appropriate privileges.
Go to Mysql Workbench>Server Status>Note down the port number
and give hostname as localhost:your port number,usually its 3306

Navicat - lost connection to mysql server at 'reading initial communication packet', system error: 0

I am getting the error listed above when trying to connect to my MySQL server via SSH public key in Navicat. I have searched endlessly trying to find a solution to this. I have made sure that the AllowTCP option is enabled, and I have tried setting the hostname to localhost and 127.0.0.1 but neither of them work, it only changes the error to Connection Refused.
Here are my connection properties:
(General Tab)
Hostname/IP Address: mydomain.com
Port: 3306
Username: myusername
Password: mypassword
(SSH Tab)
Hostname/IP Address: mydomain.com (have also tried localhost/127.0.0.1)
Port: 3850 (this is the correct port)
Username: myusername
Authentication Method: Public Key
Private Key: C:\Path\To\My\Key
Passphrase: mySSHpassword
I know that probably isn't much help because there's not really any "settings" other than the ports, which I know are correct.
I am running these exact same credentials on my Macbook which runs SequelPro and it works flawlessly, so I'm lost as to why I can't get it working on my PC through Navicat.
Thanks for any help you can provide.
The General tab would be set to localhost (or 127.0.0.1) and the username and password would be the database credentials, not the host credentials.
Then the SSH tab would be your host with the username password you use to ssh to the host. It should be the normal ssh port 22.
I was able to get my Navicat connected using SSH to my Rackspace MySql database from my OS X (MacBook).
The key was the settings in the General Tab. I had to set the HostName/IP to the remote name of the MySql Server.
[identifier-from-the-mysql-hostname-instance].rackspaceclouddb.com then the username and password as defined for my MySql database.
The SSH described in the prior responses, matched my settings.

HeidiSQL connecting to mysql server - Lost connection...server at reading initial

New to connecting to databases and have no clue to where to begin to troubleshoot -
I am currently using HeidiSQL to connect to an external Mysql Database Server hosted on the Amazon Web Service - EC2.
I am able to access the database using HeidiSQL with the settings:
MySQL (SSH tunnel)
Hostname/ip: 127.0.0.1
user: (user)
password: (pw)
port 3306
in SSH tunnel tab:
plink.exe location is set to putty.exe
sshhost + port: (my host ip) port 22
private key file: (is set)
local port: 3307
Using this configuration I AM able to log into my database.
My problem is when I am trying to do it using my own putty commands using the port forwarding:
In Putty:
I set SSH>tunnels - source port: 3307, destination (my host ip):3306
Local and Auto.
I connect using my passwords and hostip
Back to HeidiSQL, I put my settings to:
MYSL (TCP/IP)
hostname: localhost
user: (user)
password(pw)
port 3307
and try to connect. I get the following error:
SL ERROR (2013): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
From what I have read, this means my ssh tunnel is working but something else is wrong. I am now at a loss on why this doesn't work. Am i not setting something else up properly? Firewalling myself? My ultimate goal is to hook up another application to communicate with the database using ODBC orJDBC using the same port forwarding idea. Are there logs to check somewhere?
You must set
AllowTcpForwarding yes
PermitTunnel yes
in /etc/ssh/sshd_config
It seem's like your're trying to do this:
http://realprogrammers.com/how_to/set_up_an_ssh_tunnel_with_putty.html
It should work. I assume the ssh server and mysql server are running on the remote machine.
In Putty: I set SSH>tunnels - source port: 3307, destination (my host ip):3306 Local and Auto. I connect using my passwords and hostip
It should be: set SSH>tunnels - source port: 3307, destination 127.0.0.1:3306 Local and Auto.
heidisql: MYSL (TCP/IP) hostname: localhost user: (user) password(pw) port 3307
Notice that if you have a MySQL service running on your local machine, on the port your trying to listen (3307 ) you'll get a 2013 error, even if the local service is down! In that case, use any arbitrary unused port.
Also, if the remote mysql server has the user table (mysql database) restricted to certain hosts this won't work. Unless you find out how the server recognize himself (computer name) and add him on the user table or simply you use the '%' wildcard.
Follow below steps it solved my issue while connecting to Live server:
Find your IP (Google - what is my ip).
Go to C-Panel of your Live Server.
Go to Remote MySQL in C-Panel.
Add IP address that you got from Step 1 and save it.
Now try to connect through Heidi SQL.
Please let me know if it helped.

Remote mysql database connection

if php uses the following server name mysqlxx.90 and the username ouxxxxxxch to connect successfully to the local database and the server IP is 1x.xx.xx.x8, what would I usually enter as the server name to connect remotely.
Confusing question... I can connect properly to the database through ssh and command line, could it be that I'm just being blocked remotely, and how would I prove this??
Just use the server IP to connect. Obviously, port 3306 will need to be open to connections and your MySQL username and password must be accepted by the server.
You can try
telnet <serverip> 3306
on the command line to see if you can connect to the server on port 3306.