Skip to content

Commit e04bb33

Browse files
authored
Update initial root password procedure (#2917) (#2937)
1 parent 1eab5f5 commit e04bb33

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

en/initialize-a-cluster.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ This document describes how to initialize a TiDB cluster on Kubernetes (K8s), sp
1414
1515
## Configure TidbInitializer
1616

17-
Refer to [TidbInitializer configuration example](<https://github.com/pingcap/tidb-operator/blob/{{{ .tidb_operator_version }}}/manifests/initializer/tidb-initializer.yaml>), [API documentation](<https://github.com/pingcap/tidb-operator/blob/{{{ .tidb_operator_version }}}/docs/api-references/docs.md>), and the following steps to complete TidbInitializer Custom Resource (CR), and save it to the `${cluster_name}/tidb-initializer.yaml` file. When referring to the TidbInitializer configuration example and API documentation, you need to switch the branch to the TiDB Operator version currently in use.
17+
Refer to [TidbInitializer configuration example](<https://github.com/pingcap/tidb-operator/blob/{{{ .tidb_operator_version }}}/manifests/initializer/tidb-initializer.yaml>), [API documentation](<https://github.com/pingcap/tidb-operator/blob/{{{ .tidb_operator_version }}}/docs/api-references/docs.md#tidbinitializer>), and the following steps to complete TidbInitializer Custom Resource (CR), and save it to the `${cluster_name}/tidb-initializer.yaml` file. When referring to the TidbInitializer configuration example and API documentation, you need to switch the branch to the TiDB Operator version currently in use.
1818

1919
### Set the cluster namespace and name
2020

2121
In the `${cluster_name}/tidb-initializer.yaml` file, modify the `spec.cluster.namespace` and `spec.cluster.name` fields:
2222

23-
{{< copyable "shell-regular" >}}
24-
2523
```yaml
2624
# ...
2725
spec:
@@ -37,22 +35,24 @@ When a cluster is created, a default account `root` is created with no password.
3735

3836
- Create a [`secret`](https://kubernetes.io/docs/concepts/configuration/secret/) to specify the password for `root`:
3937

40-
{{< copyable "shell-regular" >}}
41-
4238
```shell
4339
kubectl create secret generic tidb-secret --from-literal=root=${root_password} --namespace=${namespace}
4440
```
4541

4642
- If you want to create more than one user, add the desired username and the password in the above command. For example:
4743

48-
{{< copyable "shell-regular" >}}
49-
5044
```shell
5145
kubectl create secret generic tidb-secret --from-literal=root=${root_password} --from-literal=developer=${developer_password} --namespace=${namespace}
5246
```
5347

5448
This command creates `root` and `developer` users with their passwords, which are saved in the `tidb-secret` object. By default, the regular `developer` user is only granted with the `USAGE` privilege. You can set other privileges in the `initSql` configuration item.
5549

50+
Make sure to do these before creating the cluster:
51+
52+
- Create the secret.
53+
- Match the `passwordSecret` in the `TidbInitializer` with the secret name that you used for the root password.
54+
- Apply `${cluster_name}/tidb-initializer.yaml` to the cluster.
55+
5656
## Set a host that has access to TiDB
5757

5858
To set a host that has access to TiDB, modify the `permitHost: ${mysql_client_host_name}` configuration item in `${cluster_name}/tidb-initializer.yaml`. If it is not set, all hosts have access to TiDB. For details, refer to [Mysql GRANT host name](https://dev.mysql.com/doc/refman/5.7/en/grant.html).
@@ -63,8 +63,6 @@ The cluster can also automatically execute the SQL statements in batch in `initS
6363

6464
For example, the following configuration automatically creates a database named `app` after the cluster creation, and grants the `developer` account full management privileges on `app`:
6565

66-
{{< copyable "" >}}
67-
6866
```yaml
6967
spec:
7068
...
@@ -79,8 +77,6 @@ initSql: |-
7977

8078
## Initialize the cluster
8179

82-
{{< copyable "shell-regular" >}}
83-
8480
```shell
8581
kubectl apply -f ${cluster_name}/tidb-initializer.yaml --namespace=${namespace}
8682
```
@@ -93,25 +89,19 @@ If the server does not have an external network, you need to download the Docker
9389

9490
The following Docker images are used to initialize a TiDB cluster:
9591

96-
{{< copyable "" >}}
97-
9892
```
9993
tnir/mysqlclient:latest
10094
```
10195

10296
Next, download all these images with the following command:
10397

104-
{{< copyable "shell-regular" >}}
105-
10698
```shell
10799
docker pull tnir/mysqlclient:latest
108100
docker save -o mysqlclient-latest.tar tnir/mysqlclient:latest
109101
```
110102

111103
Next, upload these Docker images to the server, and execute `docker load` to install these Docker images on the server:
112104

113-
{{< copyable "shell-regular" >}}
114-
115105
```shell
116106
docker load -i mysqlclient-latest.tar
117107
```

0 commit comments

Comments
 (0)