标签:
成功方案
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[root@localhost ~]# mysql -u root mysql
mysql> update user set authentication_string=PASSWORD(‘passw0rd‘) where user=‘root‘;
[root@localhost ~]# mysql -u root -p
Enter password:
登陆之后还需之行下面的语句修改密码,使其符合规则
alter user ‘root‘@‘localhost‘ IDENTIFIED BY ‘Passw0rd@‘ PASSWORD EXPIRE;
或者这一句
SET PASSWORD = PASSWORD(‘Passw0rd@‘);
使mysql的root用户可以远程链接:
mysql -u root –p
mysql>use mysql;
mysql>
update
user
set
host =
‘%‘
where
user
=
‘root‘
;
mysql>
select
host,
user
from
user
;
FLUSH
PRIVILEGES
失败方案
创建mysql-init文件,内容如下:
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘MyNewPass‘;
然后执行 sudo mysqld_safe --init-file=mysql-init &
然后删除mysql-init
标签:
原文地址:http://www.cnblogs.com/yoyogis/p/5609193.html