百度智能云

All Product Document

          Relational Database Service

          Connect to the RDS Instance

          Connection Scenarios

          Connection scenarios supported by the RDS include:

          • BSS, access via Intranet
          • BAE (Professional), access via Intranet
          • BAE Basic, access via the cloud network
          • 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
          • Cloud network connection: set whitelist, enable 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 might result in data loss!
          • After the creation of the RDS instance, all IPs are allowed, which facilitates the user's connection. To ensure data security, users must reset the whitelist before access to the database.

          Enable the cloud network access

          The user can access the RDS database through the 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.

          image.png

          Direct access via code

          The user can directly access the database through the domain name or IP address in the code. If accessing through a 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 via 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 the RDS instance.

          The syntax for MySQL to connect the RDS:

          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 via phpMyAdmin

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

          1. At the top right corner of the "the RDS -Instance List" page, click the "Database Management Tool" to enter the "phpMyAdmin" login page. Here, users may manage datasheet, view data, and import/export data. by "phpMyAdmin".

          image.png

          1. Log in to "phpMyAdmin" by account and password created on the "Account Management" tab.

          If other database management tools are used, domain name or IP address of the "Basic Information" page of the instance can be filled as the database address, and account and password created on the "Account Management" tab can be used.

          Previous
          Create an Account
          Next
          Create a Database