Connection in Linux Operating System

<p>This article describes how to install a PostgreSQL client on the ECS in Linux operating system and access an RDS PostgreSQL instance via a PostgreSQL client.</p> <p><span style="font-size:18px"><strong>Prerequisites</strong></span></p> <ol> <li>You have successfully created an RDS PostgreSQL instance. For more information, see <a href="http://pinganyun.com/ssr/help/database/RDS/Getting_Started.RDS_PostgreSQL.Create_RDS_PostgreSQL" target="_blank">Create an RDS PostgreSQL Instance</a>.</li> <li>You have successfully created an ECS. For more information, see <a href="http://pinganyun.com/ssr/help/database/RDS/Getting_Started.RDS_PostgreSQL.Create_ECS" target="_blank">Create an ECS</a>, and the instance is in the status of running.</li> <li>You have successfully opened a whitelist. For more information, see <a href="http://pinganyun.com/ssr/help/database/RDS/Getting_Started.RDS_PostgreSQL.Create_Whitelist" target="_blank">Open a Whitelist</a>.</li> </ol> <p><span style="font-size:18px"><strong>Procedures</strong></span></p> <p>1.&nbsp; Log in to a Linux&nbsp;ECS instance. For more information, see&nbsp;Log In to Instance.&nbsp;</p> <p>2.&nbsp; Execute the following command to open the xxx.repo file.</p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200207145210-17205acc91c8.png" style="height:22px; margin:0px; width:90px" />: The&nbsp;<em>xxx&nbsp;</em>parameter specifies a user-customized&nbsp;file name.</p> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="background-color:#f7f8fa; vertical-align:top"> <p><span style="font-family:Consolas">cd /etc/yum.repos.d</span></p> <p><span style="font-family:Consolas">vim xxx.repo</span></p> </td> </tr> </tbody> </table> <p>3.&nbsp;&nbsp;Add the following content to&nbsp;the xxx.repo file.</p> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="background-color:#f7f8fa; vertical-align:top"> <p>[<em>postgresql</em>] &nbsp; //Customize the name based on your need.</p> <p><span style="font-family:Consolas">name=postgresql11-rhel-7-x86_64</span></p> <p><span style="font-family:Consolas">baseurl=http://yum.cloud.papub/postgresql/repos/yum/12/redhat/rhel-8-x86_64/</span></p> <p><span style="font-family:Consolas">enabled=1</span></p> <p><span style="font-family:Consolas">gpgcheck=0</span></p> </td> </tr> </tbody> </table> <p>4.&nbsp;&nbsp;Execute the following command to update yum installation source.</p> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="background-color:#f7f8fa; vertical-align:top"> <p><span style="font-family:Consolas">yum clean all &amp;&amp; yum makecache</span></p> </td> </tr> </tbody> </table> <p>5.&nbsp; Execute the following command to disable the default PostgreSQL software.</p> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="background-color:#f7f8fa; vertical-align:top"> <p><span style="font-family:Consolas">yum -qy module disable postgresql</span></p> </td> </tr> </tbody> </table> <p>6.&nbsp; Execute the following command to install the PostgreSQL client.</p> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="background-color:#f7f8fa; vertical-align:top"> <p><span style="font-family:Consolas">yum install postgresql11</span></p> </td> </tr> </tbody> </table> <p>7.&nbsp; Execute the following command to connect to an RDS PostgreSQL&nbsp;instance.</p> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="background-color:#f7f8fa; vertical-align:top"> <p>psql -h <em>Domain-name</em> -p <em>Port</em> -U <em>Postgresql_Account</em> -d postgres -W</p> </td> </tr> </tbody> </table> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200207145210-17205acc91c8.png" style="height:22px; margin:0px; width:90px" />:</p> <ul> <li>-h <em>Domain-Name</em>: Domain name of the RDS PostgreSQL instance. For more information, see <a href="http://pinganyun.com/ssr/help/database/RDS/User_Guide_RDS_PostgreSQL.Instance_Management.View_Instance.View_Common_Instance" target="_blank">View Basic Information about an Instance</a>.</li> <li>- RDS: Port&nbsp;number of the RDS PostgreSQL instance. For more information, see <a href="http://pinganyun.com/ssr/help/database/RDS/User_Guide_RDS_PostgreSQL.Instance_Management.View_Instance.View_Common_Instance" target="_blank">View Basic Information about an Instance</a>.</li> <li>-U <em>Postgresql _Account</em>: Name of the administrator that has been created. For more information, see <a href="http://pinganyun.com/ssr/help/database/RDS/User_Guide_RDS_PostgreSQL.Instance_Management.Create_Instance.Create_Common_Instance" target="_blank">Create a General Instance</a>.</li> <li>-d postgres: Name of the database&nbsp;to be connected. The default is postgres database.</li> <li>-W: Password that you have set for the user. The password is required. After executing the command above, enter the password as prompted. For more information, see <a href="http://pinganyun.com/ssr/help/database/RDS/User_Guide_RDS_PostgreSQL.Instance_Management.Create_Instance.Create_Common_Instance" target="_blank">Create a General Instance</a>.</li> </ul> <p><span style="font-size:18px"><strong>Result</strong></span></p> <p>The client is successfully connected to the RDS PostgreSQL instance.&nbsp;</p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20191507142406-162c0ff29369.png" style="height:94px; width:644px" /></p>
Did the above content solve your problem? Yes No
Please complete information!

Call us

400-151-8800

Email us

cloud@pingan.com

Online customer service

Instant reply

Technical Support

cloud products