百度智能云

All Product Document

          Distributed Relational Database Service DRDS

          Connect to an Instance

          Connection description

          There are several ways to connect the DRDS instances, such as access through database management tools or through domain name address in the code. Regardless of the way of access to the database, the address, port number, account and password information of the database are required.

          Among them, the address of the database is the domain name or IP address, and the port number of the DRDS instance. You can click the instance name to enter the "Basic Information" page of the instance to view.

          You need related account and password to access the database. For the account creation, see Account Management.

          Enable the public network access

          The user can access the DRDS database through private network and public network. By default, the public network does not get enabled for the database. If there are requirements for access to the public network, the public network access needs to be enabled through the following operations.

          Enter the “DRDS - Instance List/Instance Details” page. Click “Enable” behind the public network access. Then, the public network is enabled after the system processing.

          image.png

          Direct access through code

          The user can directly access the database through domain name or IP address in the code. In case of access through the public network, you need to enable the public network access to the database. Take the “Link the database through the PHP code” as an example:

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

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

          Access via the MySQL client

          The MySQL database does not only provide server applications of the database, but also provides a large number of client tools and programs, such as MySQL, mysqladmin, and mysqldump. Among them, the MySQL provides a command line interface for users to operate and manage the MySQL server. In this section, we take the MySQL as an example to introduce how to connect to the RDS instance.

          The syntax for connecting the MySQL to the RDS is as follows:

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

          Note: Among them, the value of the servername is the domain name or IP address on 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 respectively. No space exists between the password and -p.

          Previous
          Log in toCreate an Instance
          Next
          Instance Management