Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 如何修改数据库密码
[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Problem Phenomenon and Impact]
After installing the cluster, how to change the password when logging into the MySQL database
[Attachment: Screenshot/Log/Monitoring]
Execute this
alter user root@'%' identified by 'XXXXXX'
Note that those are single quotes; the ones copied from the community might turn into Chinese quotes.
use mysql;
SET PASSWORD FOR ‘root’@‘%’ = ‘xxxx’;
update user set authentication_string=“xxx” where user=“root”; (Choose one of the commands to set the root password)
mysql> create user 'test'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.02 sec)
mysql> select User,authentication_string from mysql.user where user='test';
+------+-------------------------------------------+
| User | authentication_string |
+------+-------------------------------------------+
| test | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+-------------------------------------------+
1 row in set (0.00 sec)
mysql> ALTER USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password AS '111111';
ERROR 1827 (HY000): The password hash doesn't have the expected format. Check if the correct password algorithm is being used with the PASSWORD() funct
ion.mysql> ALTER USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9';
Query OK, 0 rows affected (0.04 sec)
mysql> show variables like 'default_authentication_plugin';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| default_authentication_plugin | mysql_native_password |
+-------------------------------+-----------------------+
1 row in set (0.00 sec)
mysql> select version();
+--------------------+
| version() |
+--------------------+
| 8.0.11-TiDB-v7.5.0 |
+--------------------+
1 row in set (0.00 sec)
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘rock’;
use mysql;
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
flush privileges;
flush privileges;
is not necessary.
There are many methods: set password; alter user; update user
The method is the same as changing the password in MySQL.
MySQL is almost the same.
You can refer to the official documentation for settings:
Read the MySQL manual more.
You can also take a look at the TiDB documentation, there are descriptions in the official documentation as well. Check the reply above.
Exactly the same as MySQL.
The correct order is to search the official documentation first before asking questions.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.