Shock! He forgot the mysql password under Linux

  1. Open the mysql folder, find the /etc/my.cnf configuration file, add skip-grant-tables at the end of /etc/my.cnf, save it, and skip authentication.
  2. Restart MySql to make the modified configuration take effect.
  3. Enter mysql at the terminal, and then enter use mysql;
  4. Terminal input update mysql.user set authentication_string=password('123456') where user='root';
  5. Remove skip-grant-tables at the end of /etc/my.cnf and save.
  6. Restart MySql, enter mysql -u root -p in the terminal, and then follow the prompts to enter the password you just set to use it normally.

Guess you like

Origin blog.csdn.net/mrliqifeng/article/details/71177419