mac下 MySql 8.0.15忘记密码重置密码

Mysql最新版跟老版用法不一样了,重置密码的方法也改变了

1、忘记密码了就需要先免登录进入数据库

进入到mysql目录下:

cd /usr/local/mysql/bin/

sudo su

终端出现:

sh-3.2#

接着输入:

./mysqld_safe --skip-grant-tables &

终端出现:

[1] 636
sh-3.2# 2019-03-13T07:13:18.6NZ mysqld_safe Logging to '/usr/local/mysql-8.0.15-macos10.14-x86_64/data/bogon.err'.
2019-03-13T07:13:18.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-8.0.15-macos10.14-x86_64/data

接着输入:

./mysql

免登录进入成功:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.15 MySQL Community Server - GPL

开始重置密码:

use mysql;


把之前密码清空:

 update user set authentication_string=''  where user='root';

刷新一下:

 flush privileges;

真正设置密码:

ALTER user 'root'@'localhost' IDENTIFIED BY '123456';

刷新一下:

flush privileges;

退出:

quit;

接着退出:

exit;

可以用刚才的密码重新登陆了

你可能感兴趣的:(java)