Grant Remote Access to mysql server installed on Google Compute Engine - mysql

i have followed all instructions give across google but somehow i am unable to get access from my desktop to a remote mysql database installed on Google Compute Engine.
I have done the following
a) create user and grant him permissions to get access remotely
b) allow the port in firewall
c) comment out bind-address
but still i get the error
when i try to connect from my remote windows client.
where i am i missing a required step??? Please help...

Ensure that you have allowed TCP traffic from your location to VM in question to port 3306 on a project level in Cloud Console or using CLI:
gcloud compute firewall-rules list
More about setting up firewalls in official documentation:
https://cloud.google.com/compute/docs/vpc/firewalls

As far as I can tell, google doesn't allow remote connections to a mysql DB on cloud engine. Only between VMs, but now with an external client.
It is only allowed if you are using a dedicated Cloud SQL instance
See the first paragraph on this article (I'd be happy to be proven wrong though):
https://cloud.google.com/solutions/mysql-remote-access

Near the bottom they indicate non-compute engine access is out of scope for the article, but tells you to basically do the same stuff and set the google firewall for external access and the db user to access from outside.

Related

Why I get inconsistent connection with MySQL Workbench and Google Cloud SQL?

I don't understand why I got inconsistent connection from my local MySQL Workbench to Google Cloud SQL.
Something, I can connect to my database the first time, sometimes, I need to try multiples times before getting a connection. Sadly, most of the time, it's not working.
Because I can rarely connect to the database, what kind of configuration can cause this problem?
Here's some infos:
My application hosted on Google Compute Engine don't have any connection problem.
My public IP (personnal computer) is added to the Authorised networks in my Google Cloud SQL instance. See: Enabling public IP and adding an authorized address
I have added a Firewall rules to allow port 3306 in Google Cloud VPC network
SSL is currently disable for the testing purpose
I followed these instructions: How to connect to your Cloud SQL instance database with MySQL Workbench
For the benefit of future readers, the result of the comments above was:
The problem was that the client was alternating between two possible external IP addresses. One had been authorized to access Google Cloud, and the other one had not been authorized.
Enable all client IP addresses to connect, and that should fix it.

Connect Google Data Studio to Local Mysql Server

I have started using Google's Data Studio I found it very easy to turn the Excel data into Intuitive Business Dashboards with little or no coding skills.
But I have a problem here, whenever I try to connect to Mysql DB (running on my local system) I'm facing error.
Connection Details:
Error Message:
I tried googling the Error Code but No luck.
But I'm able to access the local Mysql Server from Mysql Workbench.
What is that I am missing here? Data Studio Heros?
Thanks in advance.
Simple answer: To expose a localhost service to the web, you have to use ngrok.
For your MySQL the command is:
ngrok tcp 3306
Then the hostname you have to use data studio will be displayed.
Google Data Studio operates on the Web, thus does not have access to your personal local network. However,
You may make you MySQL db Engine accessible to the web by changing the bind-address parameter (See on MySQL Workbench, Instance > Option File > Networking > General > bind-address) to 0.0.0.0.
You also need to create a new user allowed to connect from Hosts Matching %, since Google Data Studio servers are using a dozen of different IP addresses (https://support.google.com/datastudio/answer/7088031?hl=en)
Please refer to this question:
How to make mySQL database at my local accessible from different machines?
Please note that this is a bad practice to open an access to your personal computer and you may instead want to use a MySQL or MariaDB cloud service such as https://console.cloud.google.com/launcher/details/bitnami-launchpad/mariadb
You cannot put host address as localhost.
1) You will need to check your device address at whatismyip.com or something like that.
2) Second thing you need to check is if your device is under firewall or not.
You can refer below URL for more information
http://qsok.com/x/KIBr
As Will mentioned above, it's best practise to use cloud service such as Google Cloud itself to host your MySql database and then take the connection there.
When you connect your database to Data Studio you need to open firewall for all the IP addresses it uses. You can find the whole list of IPs on the bottom of this support article https://support.google.com/datastudio/answer/7088031?hl=en
If your database is behind a firewall, you will need to open access to
the all of the following IP addresses. These are used by Data Studio
to connect to and query your MySql database.

Access MySQL server remotely

I install mysql manually by sshing the virtual disk of google compute engine . I already create user by following this mysql-adding-user-for-remote-access
and I bind address = 0.0.0.0 then restart mysql service, when I connect remotely using external ip address and the created user it doesn't work. How can I connect I am using HeidiSQL mysql client tool.
Thank you in advance.
By default - the mysql port is closed on google cloud platform. If you want to allow external access you should open that port in the firewall.
To do so you can run (using gcloud):
$ gcloud compute firewall-rules create "mysql-remote-access" --allow tcp:3306 --source-tags "mysql-client" --target-tags "mysql-server"
(Or use the CONSOLE for that: https://console.cloud.google.com/firewalls/add?_ga=1.140859190.569287361.1481048942 )
Note that you will also need to create a user (in mysql) that has access privileges from your own IP, and set this user privileges to allow access to the database you are using).
In my case, I had to also open the firewall within Windows in addition to opening the port using Google VPC networking.
Make sure both boxes (public and private) are checked next to MySQL 57 in the Windows Firewall app.

ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xx.xx' (10060)

I'm trying to connect my local MySQL to a test 2nd generation MySQL instance on Google SQL platform using the following command on my windows laptop.
mysql --host=130.211.xx.xx --port=3306 --user=root --password
I double checked my IP address with whatismyIPaddress.
I can connect via Google Cloud Shell on the Google Platform itself and also ping the IP address from the local cmd prompt.
As a troubleshooting step I have disabled the local firewalls on my laptop and granted full access to 0.0.0.0/0 to allow all connections on the google platform console.
still no joy from either a cmd line connection on windows or using a putty client, can anyone give me any further pointers on the missing step?
Cheers..
If you are behind a NAT your IP might change which prevents you from accessing the Cloud SQL instance. I would recommend setting up access using SSL certificate. More information about the setup can be found in this Help Center article.
You may need to allow remote connections to your remote database in the server and database configuration. These kinds of connections are typically disabled by default.

Google Compute Engine LAMP Stack SFTP,SQL and HTTPS

I've setup a google compute VM, and can access phpmyadmin and the default index page. SSH works when I click the button on the website.
I am having issues remotly connecting to my server instance for any sort of management(ftp or sql)
I followed the firewall section here: https://cloud.google.com/solutions/mysql-remote-access
But I still can't connect.
My firewall is configured:
And I have no idea how to get HTTPS working, But it can be a problem to take care of in the future when I fully switch my site over the compute engine. Since I can't switch my domain or current SSL certificates over yet.
EDIT:
More information:
When I try to connect to SQL using client "Sequel Pro" it returns:
With telnet:
When I try connect to SFTP I get:
Could this be caused by me mistyping the password?
Your firewall settings show that you allowed external traffic to both ports 21 and 3306 for TCP protocol. This is good but not enough.
In order to allow remote connections to MySQL, you will need to grant remote access to your username and your external IP address. Take a look at this case for an example. This is also mentioned in step 6 and step 7 of Configure MySQL server on my-server section of the article you specified:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'TESTUSER'#'<external-ip-my-client>' IDENTIFIED BY '<some-password>';
About the ftp server, the VM instance comes with no ftp service installed, but instead you can use SFTP protocol to connect to it which is more secure than FTP protocol and is highly recommended. Use gcloud compute config-ssh to generate SFTP/SSH key pair. For more information visit Setting up secure FTP on Google Compute Engine artcile.