当前位置:网站首页>Modify the root password of MySQL

Modify the root password of MySQL

2022-07-23 11:55:00 Summer invasion bug planning

modify mysql Of root password

Method 1: use SET PASSWORD command

Log in first MySQL.
Format :mysql> set password for user name @localhost = password(‘ New password ’);
Example :mysql> set password for [email protected] = password(‘123’);

Method 2: use mysqladmin

Format :mysqladmin -u user name -p Old password password New password
Example :mysqladmin -uroot -p123456 password 123

Method 3: use UPDATE Direct editing user surface

Log in first MySQL.
mysql> use mysql;
mysql> update user set password=password(‘123’) where user=‘root’ and host=‘localhost’;
mysql> flush privileges;

Method 4: Forgetting root When it comes to passwords , It can be like this

With windows For example :

  1. Close running MySQL service .
  2. open DOS window , go to mysql\bin Catalog .
  3. Input mysqld --skip-grant-tables enter .–skip-grant-tables It means to start MySQL Skip authority list authentication when serving .
  4. Open another one DOS window ( Because that one DOS The window can no longer move ), go to mysql\bin Catalog .
  5. Input mysql enter , If it works , Will appear MySQL Prompt >.
  6. Connect to permission database : use mysql; .
  7. Change password :update user set password=password(“123”) where user=“root”;( Don't forget to add a semicolon at the end ) .
  8. Refresh the permissions ( Steps must be taken ):flush privileges; .
  9. sign out quit.
  10. Log off the system , Enter again , Use the user name root And the new password you just set 123 Sign in .
原网站

版权声明
本文为[Summer invasion bug planning]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207230538361823.html