Linux系统连接
<p>本文主要介绍在安装了MySQL客户端的ECS上,如何访问DRDS实例。</p>
<p><span style="font-size:18px"><strong>前提条件</strong></span></p>
<p>1. 您已成功创建ECS,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/quick_start.Create_ECS" target="_blank">创建ECS</a>,且实例处于运行中。</p>
<p>2. 您已在ECS上成功安装MySQL客户端,可参考<a href="https://www.ocftcloud.com/ssr/help/database/RDS/Getting_Started.RDS_MySQL.Connect_RDS_MySQL.Linux" target="_blank">Linux系统连接</a>。</p>
<p>3. 您已成功创建DRDS实例,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/quick_start.Create_DRDS" target="_blank">创建DRDS实例</a>,且实例处于运行中。</p>
<p>4. 您已成功绑定账号与数据库,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/quick_start.Binding_Account" target="_blank">授权账号与逻辑库权限</a>。</p>
<p>5. 您已成功开通白名单,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/quick_start.Create_Whitelist" target="_blank">开通白名单</a>。</p>
<p><span style="font-size:18px"><strong>注意事项</strong></span></p>
<p>ECS的操作系统请选择CentOS 7.x、RedHat Linux 7.x、Oracle Linux 7.x及以上的版本。</p>
<p><span style="font-size:18px"><strong>操作步骤</strong></span></p>
<p><span style="font-size:16px"><strong>安装MySQL客户端</strong></span></p>
<p>可参考<a href="https://www.ocftcloud.com/ssr/help/database/RDS/Getting_Started.RDS_MySQL.Connect_RDS_MySQL.Linux" target="_blank">Linux系统连接</a>。</p>
<p><span style="font-size:16px"><strong>连接DRDS实例</strong></span></p>
<p>在MySQL客户端,执行以下命令,连接DRDS实例。</p>
<p>• 指定数据库连接:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">mysql -h<em>Domain-name</em> -u<em>Mysql_Account</em> -D<em>Database-name</em> -P<em>Port</em> -p<em>Password</em></span></p>
</td>
</tr>
</tbody>
</table>
<p>• 不指定数据库连接,会连接至默认的系统数据库:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">mysql -h<em>Domain-name</em> -u<em>Mysql_Account</em> -P<em>Port</em> -p<em>Password</em></span></p>
<p><span style="font-family:Consolas">use <em>Database-name</em></span></p>
</td>
</tr>
</tbody>
</table>
<p> <img src="https://obs-cn-shanghai.ocftcloud.com/pacloud/20191909104030-169e38b19d40.png" style="height:26px; margin:0px; width:65px" />:</p>
<p> • -h<<em>Domain-name</em>>:DRDS实例的访问域名,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/manual.Instance_Management.Configuration_Management.View_Instance" target="_blank">查看实例基本信息</a>。</p>
<p> • -P<<em>Port</em>>:DRDS实例的连接端口,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/manual.Instance_Management.Configuration_Management.View_Instance" target="_blank">查看实例基本信息</a>。</p>
<p> • -u<<em>Mysql_Account</em>>:连接DRDS实例的账号名称,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/manual.Instance_Management.Account.Create_Account" target="_blank">创建用户</a>。</p>
<p> • -<span style="font-family:Microsoft Yahei">p</span><<em>Password</em>>:创建账号时设置的密码,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/quick_start.Create_User" target="_blank">创建用户</a>。</p>
<p> • -D<<em>Databases-name</em>>:连接DRDS实例的逻辑库,可参考<a href="https://www.ocftcloud.com/ssr/help/database/DRDS/manual.Database_Management.DB_Management.Create_Database" target="_blank">创建逻辑库</a>。</p>
<p><span style="font-size:18px"><strong>执行结果</strong></span></p>
<p>成功连接DRDS实例。</p>
提交成功!非常感谢您的反馈,我们会继续努力做到更好!