Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update the Forgot root password (#11974) #12779

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 37 additions & 10 deletions user-account-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,47 @@ TiDB stores passwords in the `mysql.user` system database. Operations that assig

## Forget the `root` password

1. Modify the configuration file by adding `skip-grant-table` in the `security` part:
1. Modify the configuration file:

```
[security]
skip-grant-table = true
```
1. Log in to the machine where one of the tidb-server instances is located.
2. Enter the `conf` directory under the TiDB node deployment directory, and find the `tidb.toml` configuration file.
3. Add the configuration item `skip-grant-table` in the `security` section of the configuration file. If there is no `security` section, add the following two lines to the end of the tidb.toml configuration file:

2. Start TiDB with the modified configuration. Use `root` to log in and then modify the password:
```
[security]
skip-grant-table = true
```

```bash
mysql -h 127.0.0.1 -P 4000 -u root
```
2. Stop the tidb-server process:

1. View the tidb-server process:

```bash
ps aux | grep tidb-server
```

2. Find the process ID (PID) corresponding to tidb-server and use the `kill` command to stop the process:

```bash
kill -9 <pid>
```

3. Start TiDB using the modified configuration:

> **Note:**
>
> If you set `skip-grant-table` before starting the TiDB process, a check on the operating system user will be initiated. Only the `root` user of the operating system can start the TiDB process.

1. Enter the `scripts` directory under the TiDB node deployment directory.
2. Switch to the `root` account of the operating system.
3. Run the `run_tidb.sh` script in the directory in the foreground.
4. Log in as `root` in a new terminal window and change the password.

```bash
mysql -h 127.0.0.1 -P 4000 -u root
```

When the `skip-grant-table` is set, starting the TiDB process will check whether the user is an administrator of the operating system, and only the `root` user of the operating system can start the TiDB process.
4. Stop running the `run_tidb.sh` script, remove the content added in the TiDB configuration file in step 1, and wait for tidb-server to start automatically.

## `FLUSH PRIVILEGES`

Expand Down