mysql- forget the root password

1, a terminal opening close MySQL: brew services stop mysql(I mac brew installation command mysql)

2, execute mysqld --skip-grant-tablescommands (-skip-grant-tables means that the time to start MySQL service permission to skip the authentication table), if the error unknown option --skip-grant-tableis executedmysqld -nt --skip-grant-tables

3, the second terminal performs open mysql -uroot -pprompted for a password, enter directly (no password)

4, select the database:use mysql;

5, update the root password:update user set authentication_string=password('新密码') where user='root' and Host='localhost';

6, refresh permissions:flush privileges;

7, exit:quit

8, re-login: mysql -uroot -pprompt for a password, then enter a password to login.

Released three original articles · won praise 4 · Views 130

Guess you like

Origin blog.csdn.net/daofengsuoxiang/article/details/104534925