Search code examples
mysqlgoogle-compute-engineheidisql

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.


Solution

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