I've recently been trying to set up a compute engine instance that will host a SQL database for one of my projects. Issue is, every time I set up an instance and get everything installed, the port I open in Google's firewall is still closed and I cannot connect externally to my SQL server.

So far, I've done the following things and they've resulted in failure:

  1. Use mysql-server instead of mariadb-server
  2. Use Debian 8 instead of Ubuntu 16.04 LTS
  3. Create instance allowing all ingress traffic

All of these result in nmap showing the port as closed (as well as ports 80 and 443, which I allowed at the instance's creation) and a MySQL client on my local computer is unable to connect to the server.

I have disabled ufw each time, so it shouldn't be causing any issues.

  • 1 and 2 sound like random flailing - why did you try those? Is your MySQL install configured to listen to external connections via bind-address? Are you able to use MySQL locally from the instance? Is MySQL running? – ceejayoz May 11 '17 at 0:44
  • @ceejayoz Yep, the server's running and I can connect with the mysql command. I have placed bind = in my.cnf. I tried those precisely for the reason you've said: random flailing. Me and a coworker have been trying to get this to work for hours, so we've tried everything we can think of. – Piper McCorkle May 11 '17 at 0:49
  • Can you share your MySQL config and a screenshot of the Google firewall config? – ceejayoz May 11 '17 at 1:00
  • Did you try opening the Google Cloud firewall? check this documentation cloud.google.com/compute/docs/vpc/using-firewalls – Diego Velez May 11 '17 at 4:05

I ended up solving this issue - Zeb and I are working together. It wasn't an issue with GCP at all, it was mysql denying the connection because bind-address was set to by default in the config located at /etc/mysql/mysql.conf.d/mysqld.cnf.

# Instead of skip-networking the default is now to listen only on`
# localhost which is more compatible and is not less secure.
bind-address            = 
# previously, changed to allow remote connections

After changing that in the config, mysql was listening on as shown by netstat -plutn.

You then need to add a remote user with access, and this post explains it perfectly.

Took a lot of digging, so hopefully this clears it up for anyone else who runs across this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.