github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/connect_database/connect-database-in-testing-environment.md (about) 1 --- 2 title: Connect database in testing environment 3 description: How to connect to a database in testing environment 4 keywords: [connect to a database, testing environment, test environment] 5 sidebar_position: 2 6 sidebar_label: Testing environment 7 --- 8 9 # Connect database in testing environment 10 11 ## Procedure 1. Use kbcli cluster connect command 12 13 You can use the `kbcli cluster connect` command and specify the cluster name to be connected. 14 15 ```bash 16 kbcli cluster connect ${cluster-name} 17 ``` 18 19 The lower-level command is actually `kubectl exec`. The command is functional as long as the K8s API server is accessible. 20 21 ## Procedure 2. Connect database with CLI or SDK client 22 23 Execute the following command to get the network information of the targeted database and connect it with the printed IP address. 24 25 ```bash 26 kbcli cluster connect --show-example ${cluster-name} 27 ``` 28 29 Information printed includes database addresses, port No., username, password. The figure below is an example of MySQL database network information. 30 31 - Address: -h specifies the server address. In the example below it is 127.0.0.1 32 - Port: -P specifies port No. , In the example below it is 3306. 33 - User: -u is the user name. 34 - Password: -p shows the password. In the example below, it is hQBCKZLI. 35 36 :::note 37 38 The password does not include -p. 39 40 ::: 41 42 