Can't connect to mysql server (LAMP) in google cloud - mysql

I installed LAMP on a VM instance on Google cloud but when i try to access mysql database remotely from my linux terminal using
$ mysql -u username -h ipaddress -p
after entering password nothing happens (no error). I tried accessing it locally via ssh it works.
Is there any other setting on cloud platform. I need to change before accessing database from a remote pc. Followed this tutorial but it just stops after entering password.
Tried commenting out bind address but didn't work. Need help.

Just to be clear, are you using the mysql command on your remote machine or through SSH?
Normally, you should never allow external access to remote MySQL for security reasons, especially if the only app accessing the data is local. (however, it's unclear if that is the reason why you can't connect)
This is how you should connect:
Connect to your remote VM using SSH (ex: ssh user#ipaddress)
THEN, connect to your MySQL instance.
When connecting using a DB editor, some editors allow MySQL connections through SSH. Sequel Pro for Mac does this very well.

Related

Error Connecting to Remote MySQL server hosted on Ubuntu from Windows

When attempting to connect to remote MySQL server from my Windows machine using MySQL workbench - I get an error about connecting to localhost (unsure where the software is picking up localhost). However when I attempt to connect through an SSH tunnel it connects just fine (I cannot use this for the software I am creating though)
when I run netstat on the server:
netstat command
...(more entries)
the bind address has been altered in mariadb and mysql configs. if there are any more configs people would like to see to help with solution please let me know. I have also set up the user in mysql to allow remote privileges:
mysql users
I am pretty confused.

port fowarding for mysql server ubuntu remote connection

I have a ubuntu 16.04 on which I run 3 servers from virtualbox (a webserver, a home file server and a mysql server).
In this mysql server I naturally have an internal ip (192.168....) and an external one.
However when I try to connect remotely to this mysql server from mysql shell, workbench or .NET connector (eg. mysql -u root -p -h 172.241.442.12) using the external IP of this virtual machine I always get ERROR: Not connected.
My question is whether to connect I have to enable port forwarding in my router (3306), just as I would do enabling 80/8080 in a webserver to make it accessible from the internet.
I never did it before and haven't find any clear tutorial either. My main purpose is to connect to this db in a vb.net application.
Thanks!
Yes, if you intend to access it in this manner you will need to forward a port. You will also need to grant access to MySQL for a user that is allowed remote access.
GRANT ALL ON somedb.* TO `user`#`123.123.123.123` IDENTIFIED BY 'somePassword'
The IP address can be a hostname, or % to match everything.
That said, unless you really need a permanant external connection to MySQL you should not expose it like this, the better option would be to tunnel the port through SSH.
ssh -N user#dbserver -L12345:localhost:3306 &
mysql -u root -h localhost -P 12345

Connect to MySQL over SSH with agent using MySQL Workbench (or other)

I use for connecting any SSH Session the Plugin keeagent in my Keepass (it works like pageant). So I haven never enter my Password an by private Key is stored in my keepass file. It exists several tools, that works fine with using a SSH agent. But I don't find a way to use a SSH Tunnel using an agent in MySQL Workbench.
Is it possible to connect with MySQL Workbench over SSH Tunnel using an agent?
If not, does anyone knows, which tool supports this feature?
MySQL Workbench does not support using an SSH agent when SSH tunnelling, only password and passphrase-less key. On the latter: it supports SSH keys only when they do not have a passphrase. This is as of MySQL Workbench 8.0.19.
The TablePlus client does support using an agent; more specifically it uses the standard ssh_config to extract the various options to use when connecting via an SSH host.
First, MySQL Workbench itself can create an SSH tunnel. You can determine all the details when you choose a connection to be TCP/IP over SSH.
And MySQL Workbench can also use any existing tunnel in the system (be it from keeagent or putty). You just have to know the used local port for the tunnel and use that for the connection in MySQL Workbench. It appears in WB as if you have a local connection then.

External database ssh connection in symfony parameters.yml

Anybody setup a connection to an external mysql database, only available via SSH, in their symfony app? Can this be done in the parameters.yml?
You have to open an SSH tunnel. See Can I SSH to MySQL with the GUI tools? or Access Your MySQL Server Remotely Over SSH.
For parameters.yml this looks like a local MySql server, wich menans there's nothing special.

how do i connect to mysql database in Linux server through windows machine

I have a MYSQL in windows that needs to connect with MYSQL in Linux server.but I want to know is there any way to connect MYSQL in Linux server without having MYSQL in windows.
Follow the following instructions:
1. Open Terminal and type in : sudo apt-get install putty
2. Click Y on subsequent messages that appear and let the installation complete.
To use Putty, go to Menu > Internet > Putty SSH client
To connect to a remote server that supports ssh login , enter the host name or the IP address of the remote host, in case you need to frequently need to login to this server , save the session by naming it something nice.
If the connection is initiated for the first time or if the server hardware configuration has changed, you may see the message. This is to ensure that you are logging in only to the trusted server that you know and not something else.Accept that.
Finally, enter user name and password to login to the server remotely, if all goes well you will see the terminal on the remote end.
connect to mysql :
type mysql -u username -p password
You can use putty software. Here is the link to download.
You can use putty for connecting mysql.
Connection string will like this
mysql -uDBUSER -pDBPASSWORD DBNAME -hHOST-IP
Or you can also use navicat or sql yog software to connect mysql on linux system on remote.