谷歌云sql中的Mysql连接 [英] Mysql Connect in google cloud sql
问题描述
我无法从 Google 云计算引擎连接到 MySQL 到 MySQL 存储.当我在浏览器上访问 172.146.221.156/test.php 时显示这样的错误消息
I cannot connect to MySQL from Google cloud compute engine to MySQL storage. When I go to 172.146.221.156/test.php on browser showing an error message like this
警告:mysqli_connect():(HY000/2002):第 21 行/var/www/html/test.php 中的权限被拒绝连接错误 (2002'
Warning: mysqli_connect(): (HY000/2002): Permission denied in /var/www/html/test.php on line 21 Connect Error (2002'
我的配置文件是:
<?php
$conn = mysqli_connect("176.154.226.114", "root", "password");
if (!$conn)
{
die('Connect Error (' .mysqli_connect_errno());
}
?>
我做错了什么?
推荐答案
in your google cloud => go to sql=> click on your instance => connections => Public IP add 0.0.0.0/0 as an allowed network then保存.
in your google cloud => go to sql=> click on your instance => connections => Public IP add 0.0.0.0/0 as an allowed network then save.
或者在 google my ip 中写下并添加它,如果您只想远程访问.
or write in google my ip and add it if you want only you have a remotely access.
这篇关于谷歌云sql中的Mysql连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!