百度智能云

All Product Document

          Relational Database Service

          Connect to an Instance

          Connection scenarios

          The connection scenarios supported by the RDS include:

          • BSS, access via Intranet
          • BAE (Professional), access via Intranet
          • BCH, access via the cloud network
          • User Local, access via the cloud network

          Connection presetting

          There are multiple ways to connect to the RDS instances, such as accessing through database management tools or accessing through domain name address in code. No matter which way to access the database you choose, the address, port number, account, and password information of the database are required. The address of the database is the domain name or IP address and port number of the RDS instance. You can click the instance name to enter the "Basic Information" page of the instance to view. The related account and password are required for database access connection. For account creation, see Database Account Management.

          • Intranet connection: Set whitelist and connect by Intranet domain name
          • Internet connection: Set the whitelist, enable the access to a cloud network, and connect by cloud network IP or domain name

          Notes:

          • Click "Get IP" to get the Intranet and Extranet IP addresses according to the domain name.
          • To ensure normal operation of the service, link the RDS by Extranet IP or domain name, link Intranet IP directly with the RDS Master/backup switchover result in data loss!
          • After the creation of the RDS instance, all IPs are allowed by default, which facilitates the user's connection. To ensure data security, users reset the whitelist before access to the database.

          Enable Internet Access

          The user can access the RDS database through a private network and cloud network. By default, the cloud network is not enabled for the database. If there is a need for cloud network access, the cloud network access needs to be enabled through the following operations.

          1. Enter the "RDS - Instance List/Instance" page.
          2. On the Basic Information page, click "Enable" next to the cloud network access to enable the access after system processing.

          Direct access by code

          The user can directly access the database through the domain name or IP address in the code. If accessing through the cloud network, the cloud network access to the database needs to be enabled. Take the PHP code linking database as an example:

          <?php
          $con = mysql_connect("servername","username","password");
          if (!$con)
            {
            die('Could not connect: ' . mysql_error());
            }
          
          ?>

          Note: The value of "servername" is the domain name or IP address of the "Basic Information" page of the instance. And, the values of "username "and "password" are the account and password created on the "Account Management" tab.

          Access by MySQL client

          The MySQL database not only provides server applications of the database, but also provides a large number of client tool programs, such as MySQL, "mysqladmin", and "mysqldump". MySQL provides a command line interface for users to operate and manage MySQL server. In this section, MySQL is taken as an example to introduce how to connect to the RDS.

          The syntax for MySQL to connect to the RDS database:

          C:\>mysql -h servername -P port -u username -ppassword

          Note: The value of "servername" is the domain name or IP address of the "Basic Information" page of the instance. The port is the port number, and the values of "username" and "password" are the account and password created on the "Account Management" tab. There must not be space(s) between "password" and "-p".

          Access by phpMyAdmin

          Users can access the created RDS by the database management tool. Baidu AI Cloud's console integrates the database management tool "phpMyAdmin", which users can use directly. In this section, phpMyAdmin tool is taken as an example.

          1. At the top right corner of the "RDS -Instance List" page, click "Database Management Tool" to enter "phpMyAdmin" login page. Here, users can manage the datasheet, view the data, and import/export the data. by "phpMyAdmin".
          1. Log in to "phpMyAdmin" by account and password created on the "Account Management" tab.

          If you use other database management tools, you can enter the domain name or IP address of the "Basic Information" page of the instance as the database address. And, you can use the account and password created on the "Account Management" tab.

          Previous
          Instance Management
          Next
          Read-Write Separation