Mac上破解MySQL密码
# 以下所有的不易与文字区分的代码皆用中文输入法中的【】来包括
步骤一:
苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服务(点击stop mysql server)
步骤二:
进入终端输入:【cd /usr/local/mysql/bin/】
回车后 登录管理员权限:【sudo su】
回车后输入以下命令来禁止mysql验证功能:【./mysqld_safe --skip-grant-tables &】
回车后mysql会自动重启(偏好设置中mysql的状态会变成running)
步骤三:
输入命令:【./mysql】
回车后,输入命令:【flush privileges;】
回车后,输入命令:【set password for 'root'@'localhost' = password('你的新密码');】
# 要改的密码得写在引号''当中
终端代码示例:
Last login: Sat May 11 21:12:20 on ttys000
SC:~ ShuChan$ cd /usr/local/mysql/bin/
SC:bin ShuChan$ sudo su
Password: # 在此需要输入的是mac的密码
sh-3.2# ./mysqld_safe --skip-grant-tables &
[1] 2233
sh-3.2# usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
2019-05-11T13:13:26.6NZ mysqld_safe Logging to '/usr/local/mysql/data/SC.err'.
2019-05-11T13:13:27.6NZ mysqld_safe A mysqld process already exists
./mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 94
Server version: 5.7.16 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> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'localhost' = password('123456');
# 要改的密码得写在引号''当中
Query OK, 0 rows affected, 1 warning (0.00 sec)