I know this topic is discussed in many threads but I still cannot find the solution for my case. I am using mysql 8.0.24 in centOS 8.0 and trying to reset my root password. Here is my user table.
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
I first started with mysql docs with below command.
`ALTER USER 'root'@'localhost' IDENTIFIED BY '111';`
But I got error, ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
And I tried with
update mysql.user set authentication_string='111' where user='root';
I got Query OK, 1 row affected (0.00 sec)
.
Then I did
FLUSH PRIVILEGES;
I checked the table with
mysql> SELECT user,authentication_string FROM mysql.user;
+------------------+------------------------------------------------------------------------+
| user | authentication_string |
+------------------+------------------------------------------------------------------------+
| mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| root | 111 |
Then I kill the safemode and start in normal model with
systemctl start mysqld
mysql -u root -h localhost -p
When I type the password 111, it says
ERROR 1045 (28000): Access denied for user 'root'@'localhost'
I really don't know why this happened. First of all, the official docs syntax doesn't work for my version. I used the update command. Nothing works.