准备工作(没有vim用edit):
sudo vim /etc/my.cnf
添加:
[mysqld]
skip-grant-tables
不可用:
set password for 用户名@localhost = password('新密码');
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
update mysql.user set password='这里填写你要设置的密码' where user='root';
可用:
update user set authentication_string = NULL where user = 'root';
删除最先添加的两行后重新进入:
mysql -u root -p
设置初始密码:
LTER USER'root'@'localhost'IDENTIFIED WITH mysql_native_password BY'123';
网友评论