Puphpet MySQL Workbench Connection in Vagrant on Cygwin - mysql

I am new to programming, and do not have much idea about ports/forwarding/connection etc.
Installed Vagrant, MySQL Workbench, and Cygwin on Windows 8.1, then
Puphpet on Cygwin and created Virtual Machine, for learning.
But, unable to connect to MySQL on Virtual Machine (MySQL Server is on, on Virtual Machine) from Workbench in Windows.
I did not do any change in vagrantfile or config.yaml.
Tried Out:
Changed to bind-address = 0.0.0.0 in my.conf, but no use.
Commented out # bind-address = 127.0.0.1 in my.conf, again
no use.
Note: (I DELETED id_rsa file when it was not properly doing vagrant up
second time. So, gave full path to id_rsa.ppk, for connecting)
Connection Method: Standard (TCP/IP over SSH)
Parameters:
Hostname: 192.168.56.101:8957
SSH Username: vagrant
SSH Password: vagrant
SSH Key File: c:\cygwin64\home\tomy\puphpet\sutfva\puphpet\files\dot\ssh\id_rsa.ppk
MySQl Hostname: 127.0.0.1
Port: 3306
Username: dbuser
Password: 123
Error message:
IO Error [Errno 10061] No Connection could be made because the target
machine actively refused it. Please refer to logs for details
The answer at Vagrant MySQL Access is not clear to me. How to configure port forwarding?
Can you please guide me in simple words, how I can establish connection? Also, how to disconnect, and any security issue.

Thank you very much Juan Treminio and Brian Morton! Both of them gave valuable tips and inputs for me to come to track! In addition, immense thanks to Juan Treminio for his https://puphpet.com which is a huge help to persons like me.
COMPLETE Connection Details:
Choose
Standard TCP/IP over SSH
Parameters (Mostly default values since I did not change it)
SSH Hostname: 192.168.56.101
SSH Username: vagrant
SSH Password: vagrant
SSH Key File: C:\cygwin64\home\tomy\puphpet\sutfva\puphpet\files\dot\ssh\id_rsa
MySQL Hostname: 127.0.0.1
MySQl Server Port: 3306
Username: root
Password: 123
Note: Remember to note down your connection parameters

Hostname: 192.168.56.101:8957
You shouldn't need the port here, you should probably just need to ender 192.168.56.101
To verify which port SQL Server is listening on, you can ssh into the box and run
netstat -lnutp
This will output a list of the currently open and listening ports on the box. If you do not see SQL Server in the list, then it is not currently running and the service will need to be started.

Related

Cannot access MySQL container in VPS from MySQL Workbench In My PC

I've created a docker container that runs MySQL on it and exposes it on the default port (3306) on a DO droplet (Ubuntu 20).
I tried accessing it on my laptop with the following parameters:
Hostname: (VPS's IP address. I also tried Public Gateway IP)
Connection: Standard (TCP/IP)
Port: 3306
Username: root
Password: (Password I have set while creating the container)
The error message just says "Could not connect to localhost"
Am I missing a step that maybe exposes the container to the internet?
After a couple of hours, I found out that the docker run command has to have -p parameter. -p=3306:3306 in my case.

Can't connect to digital ocean LEMP stack MySql via Workbench (or any gui) but CAN connect via terminal mysql cmd

I have tried suggestions in what seems like every post about this topic and none of them have worked for me, so I'm posting my own in case anyone spots anything that I missed.
I'm migrating a wordpress site into a LEMP (ubuntu, apache) stack instance on Digital Ocean, and I need temporary access to the database via MySQL Workbench or something similar on my local machine. I'm planning to turn it off once the migration is done. However I am having a very weird issue I can't figure out the cause for.
If I attempt to sign into the sql instance using
mysql -u user -h my.ip.address -p
I can get access from my local machine just fine.
I can also SSH into the server itself via terminal just fine, I have it set up in my ssh config file using the same ip address and the same user and ssh key i'm attempting to use for my workbench connection.
However doing the same via an SSH connection on workbench I constantly get the error:
Authentication failed, access denied.
Failed to connect to MySql at my.ip.address:3306 through ssh tunnel at user#127.0.0.1 with user mysqluser
Things I've done to attempt to rectify this:
set bind-address in mysql config to 0.0.0.0 on the server and restarted server's mysql
set bind-address in mysql config to my.ip.address on the server and restarted
allowed tcp connection
allowed connection via ufw firewall to 3306 and 33060 ports
created a mysql user with all privileges granted for 'localhost', '%', and '0.0.0.0' hosts
tried sshing in as root user
tried using the root user for the mysql user
I am probably missing some things on that list as I feel like I've tried a million things already!
I even have a different server on a LAMP stack (not LEMP) that I set up a few days ago and was able to gain access to the mysql db on workbench by following the same steps, and even attempted backtracing and copying what I did on the LAMP server, but no go.
I checked to see the netstats of the mysql instance and match the port and the ip and that didn't work, I made sure the port of the SSH was correct, nothing is working.
Does anyone have any tips? I've been using all of the "allow remote mysql connection on digital ocean" articles and questions i can find but nothing is working.
Here is my Workbench connection config at the moment but i have tried what feels like every iteration of it i could think of (re users, passwords, IP addresses, and ports)
SSH Hostname: my.ip.address
SSH Username: user
SSH Password: user-password (also tried empty, since i have a key)
SSH Key File: same key file i use to ssh on terminal
Mysql Hostname: 127.0.0.1 (also tried my.ip.address)
MySql Server Port: 3306 (also tried 33060)
Username: MySqlUser
Password: MySqlUser-Password (works when connecting to mysql via terminal)

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.

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.

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.