3

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.

Community
  • 1
  • 1
jemz
  • 4,987
  • 18
  • 62
  • 102

2 Answers2

5

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).

Dekel
  • 60,707
  • 10
  • 101
  • 129
  • I am sshing the GCE then i use sudo followed your command, it gives me this error ERROR: (gcloud.compute.firewall-rules.create) Some requests did not succeed: - Insufficient Permission – jemz Dec 06 '16 at 18:44
  • @jemz, are you sure you have enough permissions to execute this comman? Read this: https://cloud.google.com/solutions/mysql-remote-access – Dekel Dec 06 '16 at 18:45
  • 1
    Do I need to install the google cloud sdk ? I think I have enough permission because I can install like composer ,php etc. I don't know why I get this error insufficient permission. – jemz Dec 06 '16 at 18:51
  • these permissions are to the machine (locally), not the gcloud. – Dekel Dec 06 '16 at 18:53
  • I am confuse with this tags "instance tags" and target-tags "mysql-server" – jemz Dec 06 '16 at 19:01
  • I use the console then I just use allow traffic 0.0.0.0 because I don't know where to create the tags, so I just use 0.0.0.0 – jemz Dec 06 '16 at 19:09
2

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.

enter image description here

Ben Wilson
  • 2,271
  • 3
  • 26
  • 35