Connecting to MySQL Instance

Preparations

  • You have initialized a RDS for MySQL instance.
  • You have created a database account and authorized specific IPs or IP ranges to access the RDS for MySQL instance.
  • You have configured security group rules for the ECC instance and the RDS for MySQL instance to allow specific IPs or IP ranges to access the RDS for MySQL instance.

Connecting from a Windows ECC Instance

  1. Log in to a Windows ECC instance.

  2. Download a standard SQL client.

  3. Login, Sign Up, and No thanks, just start my download. will appear on the page. Select No thanks, just start my download. to download quickly.

  4. Install MySQL Workbench on this ECC instance

  5. Open MySQL Workbench, select Database > Connect to Database, enter the private (or public) network address, username, and password of your RDS for MySQL instance and click OK to log in.

  6. After successful login, the following page will appear, where you can view the modes and objects of the MySQL database, create tables, and perform operations such as data insertion and query.

Connecting from a Linux ECC Instance

1. Log in to the Linux ECC instance.

2. Taking a ECC instance on CentOS 7.2 (64-bit) as an example, run the following command to install the MySQL client.

yum install mysql
If Complete! is displayed, the MySQL client is installed successfully.

3. Perform the corresponding operation based on the connection method:

Private network connection:
1. Run the following command to log in to the RDS for MySQL instance
  1. - hostname: replace it with the private network address of the target RDS for MySQL instance, which can be viewed on the instance details page in the RDS for MySQL console.<BR>

Note:
The default port number of MySQL is 3306.
If the port number is 3306, you only need to replace hostname with the IP address. For example, if the private network address is 10.16.0.11:3306, set hostname to 10.16.0.11.
If the port number is not 3306, you need to specify the port in the connection command in the format of mysql -h hostname -P port -u username -p, such as mysql -h 10.16.0.11 -P 5308 -u username -p.

  • username: replace it with the default username root.
    2. Enter the password corresponding to the root account of the RDS for MySQL instance after Enter password: is prompted. If you forgot the password, you can reset it as instructed in Resetting Password.
    If MySQL [(none)]> is displayed, you have logged in to MySQL successfully.
    Public network connection:
  1. Run the following command to log in to the RDS for MySQL instance
  2. Enter the password corresponding to the public network connection username after Enter password: is prompted. If you forgot the password, reset it as instructed in Resetting Password.
    In this example, hostname is 59281c4exxx.myqcloud.com and public network port is 15311.

4. Under the MySQL [(none)]> prompt, you can send an SQL statement to the MySQL server for execution. For specific command lines, see mysql Client Commands.

Below uses show databases; as an example: