问题原文
原帖链接 · Piper McCorkle · CC BY-SA 3.0
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:
- Use
mysql-serverinstead ofmariadb-server - Use Debian 8 instead of Ubuntu 16.04 LTS
- 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.
已采纳解答
原帖链接 · ztaylor54 · CC BY-SA 3.0
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 127.0.0.1 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 = 0.0.0.0
# 127.0.0.1 previously, changed to allow remote connections
After changing that in the config, mysql was listening on 0.0.0.0:3306 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
