php - 如何从 GoDaddy 服务器连接到 Google Cloud SQL 数据库
问题描述
我正在尝试从托管在 godaddy 服务器上的网站连接到谷歌云上的 sql 实例。
我收到以下错误
Failed to connect to MySQL: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (110)
我已将 IP 授权给我的 Godaddy 服务器。
这是我处理连接的方式...
<?php
// Change this to your connection info.
$DATABASE_HOST = 'xxx.xxx.xxx.xxx';
$DATABASE_USER = 'user';
$DATABASE_PASS = 'pass';
$DATABASE_NAME = 'db';
// Try and connect using the info above.
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if ( mysqli_connect_errno() ) {
// If there is an error with the connection, stop the script and display the error.
die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}
?>
我已经被卡住了一段时间,没有在网上看到任何可以提供帮助的东西。
解决方案
推荐阅读
- python - 从文本中删除所有出现的双引号(python csv)
- javascript - 从转换字符串中提取不同的 css 转换?
- reactjs - fetchMock 函数进行实际的 API 调用,而不是模拟请求
- android - Android Studio:带有 getSupportActionBar() 的 NullPointerException
- java - Java MVC 无效监听器
- wpf - WPF 切换切换按钮内容
- regex - Bash SED 字符串替换 - 删除正则表达式前后的字符
- json - 在 React 中映射包含点的数据
- regex - 单行正则表达式中的负前瞻
- sql - 将值名称添加到第一个表 sql 中的上一列