MySql 5.7.13 for Mac 密码重置教程(适合忘记密码)

xiaoxiao2021-02-28  131

密码错误的终端信息如下所示:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)或者:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 忘记密码的解决方式就是重新设置密码,首先通过终端停止 MySQL 服务:

FSdeMacBook-Pro:mysql fs$ support-files/mysql.server status SUCCESS! MySQL running (9872) FSdeMacBook-Pro:mysql fs$ support-files/mysql.server stop Shutting down MySQL . SUCCESS! 通过安全模式运行 MySql 并且跳过授权:

FSdeMacBook-Pro:bin fs$ ./mysqld_safe --skip-grant-tables & [1] 9933 FSdeMacBook-Pro:bin fs$ 2017-09-01T02:48:32.6NZ mysqld_safe Logging to '/usr/local/mysql/data/FSdeMacBook-Pro.local.err'. 2017-09-01T02:48:32.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data 这时候我们会发现 MySQL 已经重新启动了:

FSdeMacBook-Pro:~ fs$ ps -ef|grep mysql 501 10023 10017 0 10:50上午 ttys000 0:00.00 grep mysql 501 9933 9878 0 10:48上午 ttys002 0:00.02 /bin/sh ./mysqld_safe --skip-grant-tables 501 10013 9933 0 10:48上午 ttys002 0:00.32 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --skip-grant-tables --log-error=/usr/local/mysql/data/FSdeMacBook-Pro.local.err --pid-file=/usr/local/mysql/data/FSdeMacBook-Pro.local.pid

在新的终端里进行登录(无需密码):

FSdeMacBook-Pro:bin fs$ ./mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.13 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> 修改密码,一定要先刷新系统权限表:

mysql> set password for root@'localhost' = password('root'); ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> set password for root@'localhost' = password('root'); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql>

至此,密码重置完成
转载请注明原文地址: https://www.6miu.com/read-69194.html

最新回复(0)