## Module 4: Connect To TiDB Instances

### Step 1. Connect to TiDB instance from the bastion host

+ From the SSH session on the bastion, connect to the TiDB instance. TiDB is exposed via an internal LoadBalancer. The `TIDB_HOST` variable contains the NLB hostname (e.g., `internal-xxxxx.elb.region.amazonaws.com`).

   ```bash
   mysql -h ${TIDB_HOST} -P ${TIDB_PORT} -u root
   ```

   Or explicitly (port 4000 is the default MySQL port for TiDB):

   ```bash
   mysql -h ${TIDB_HOST} -P 4000 -u root
   ```

   ```output
   mysql>
   ```

### Step 2. Execute SQL query

+ Verify the version of TiDB cluster.

  ```sql
  SELECT TIDB_VERSION(), VERSION(), NOW()\G
  ```

  ```output
  *************************** 1. row ***************************
  TIDB_VERSION(): Release Version: v8.1.1
  Edition: Community
  ...
       VERSION(): 8.0.11-TiDB-v8.1.1
           NOW(): 2025-01-19 14:20:05
  1 row in set (0.00 sec)
  ```

### Step 3. Exit from mysql client to the Linux prompt

   ```sql
   EXIT;
   ```

   ```output
   Bye
   ```
