这是我第一次尝试创建一个可由用户远程访问的sql服务器。我相信我已经正确设置了它,但是无法远程连接到我的服务器。
运行sudo mysql -u user1 -h <google vm external ip address> -p
时,输入密码后出现以下错误
ERROR 2003 (HY000): Can't connect to MySQL server on '<google vm external ip address>' (11 "Resource temporarily unavailable")
我试图找出可能的原因,但似乎只找到与服务器处于脱机状态(不是)有关的文章,或者到目前为止我已经完成的设置步骤。如果有人有任何进一步的步骤,我也许可以检查一下。
mysql Ver 15.1 Distrib 10.1.44-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 Connection id: 33 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04 Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 UNIX socket: /var/run/mysqld/mysqld.sock Uptime: 38 min 12 sec
%
将允许我的用户从任何地方进行连接,如下所示创建了用户设置。+-----------+-------+ | host | user | +-----------+-------+ | % | user1 | | localhost | user1 | | localhost | root | +-----------+-------+
/etc/mysql/mariadb.conf.d/*.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 = 127.0.0.1
答案 0 :(得分:0)
第一次使用服务器的用户...原来google vm阻止了mysql或postgres之类的所有传入内容,因此您需要为此在防火墙规则中创建一个例外。
我发现在规则中设置排除项很有帮助-https://cloud.google.com/vpc/docs/firewalls?authuser=1