连接云数据库实例
文章描述连接云数据库实例的方法
通过云服务器连接SSH和主机名
使用下列步骤使用安全shell和主机名通过云服务器连接
登录到云控制板.
顶部导航栏点击华体会联盟hth选择产品>机载云.
选择数据库> MySQL.
点击想连接实例的名称
复制主机名字符串
从终端窗口使用SSH登陆云服务器下行代码显示SSH命令示例
ssh用户@IPad
服务器上使用 MySQL客户端(或类似工具)访问数据库MySQL使用下命令并粘贴主机名串
-h
选项 :mysql-h主机名_string-u数据库_instance_username-p
直接连接数据库使用主机名
本节显示如何使用样本脚本显示简单网页显示网页帮助测试连接数据库实例
网络服务器必须和数据库实例同处区域,以便它能通过云专用网络连接实例
进程假设Web服务器和PHP配置正确
复制并粘贴PHP脚本
拷贝以下PHP脚本并粘贴成文本编辑器
连接云数据库 - 华体会足球软件
ss,$argexr,$value, mysql_errormysql_free_result($result)!mysql_close($connection)!}?
华体会联盟hthPHP简单示例测试你与Rackspace云数据库连接数据库不要求有表格双工法计算浏览器中的简单 MySQL表达式
样本使用字符串解析编译 SQL语句,仅在密码保护网站开发环境使用 sQL语句
华体会联盟hthEXAMPLES: PI()3*3cruate()3=3和4>4MID
复制实例主机名
使用下列步骤复制实例主机名
- 登录到云控制板.
- 顶部导航栏点击华体会联盟hth选择产品>机载云.
- 选择数据库> MySQL.
- 点击名称实例并查看细节实例
- 复制主机名字符串
粘贴实例主机名成文本编辑器
使用下列步骤粘贴实例主机名成文本编辑器
定位文本编辑器脚本行 :
华体会联盟hth$THE_HOST = "5c70345ad036fc112dc0a14ee1db7992f5c172db.rackspaceclouddb.com";
双引号内粘贴主机名字符串,替换下列值:
华体会联盟hth5c70345ad036fc112dc0a14ee1db7992f5c172db.rackspaceclouddb.com
修改脚本中信息指定数据库用户、密码和数据库实例名
使用下列步骤修改脚本:
定位文本编辑器脚本行 :
Unitedth_USER=fmdb_read
替换
fmdb只读
值与数据库用户名可查找信息用户群数据库实例小节云控制板.定位文本编辑器脚本行 :
$THE_PWD=fmdb
替换
fmdb只读
带密码值用户定位文本编辑器脚本行 :
USTHE_DB=FEAUREMANIA
替换
风景
使用数据库名值将修改脚本编辑.php例举clouddatabases.php)
if you change脚本文件名clouddatabases.php中修改下行替换clouddatabases.php值选择脚本名
拷贝修改脚本并用服务器执行
使用以下步骤拷贝修改脚本并用脚本执行
服务器 :
将修改脚本拷贝到服务器上(例如拷贝到网站上)gi-bin文件夹)
运行脚本测试数据库连接
连接数据库成功时,网页运行并显示类似下列消息:
数据库连接有效 MySQL表示PI()*3*3=28.2734
类型 MySQL表达式PI()*3*3并点击提交评估它
使用云负载平衡器连接
本节描述如何使用云负载平衡器连接
您应该使用负载平衡器访问云数据库实例不向负载平衡器添加其他节点
复制实例主机名
使用下列步骤复制实例主机名
- 登录到云控制板.
- 顶部导航栏点击华体会联盟hth选择产品>机载云.
- 选择数据库> MySQL.
- 点击实例名连接负载平衡并查看细节实例
- 注意数据库所在区域在同一区域创建负载平衡器
- 复制主机名字符串
创建负载平衡器实例
使用下列步骤创建负载平衡器实例
- 云控面板顶部导航栏点击网络化.
- 菜单下创建资源中键负载平衡器.
- 输入负载平衡器名
- 指定数据库实例所在的相同区域
- 内配置段选择公共互联网访问面向虚拟IP选项 。
- 选择MySQL面向协议/港.
- 内添加节点段点击添加外部节点.
- 粘贴数据库实例的主机名字符串IP或主机名字段内
- 输入默认 MySQL端口3306中端口字段内
- 点击添加外部节点.
- 点击创建加载平衡器.
负载平衡器创建后数据库可通过负载平衡器存取
使用负载平衡器访问数据库实例产生正常负载平衡和带宽收费更多信息见云加平衡计数计算器.
使用公共IP地址连接高可用性实例
高可用云数据库实例连接信息使用公共互联网协议地址见高可用云数据库.
更新 大约2个月前