#1.停止mysql数据库
/etc/init.d/mysqld stop
#2.执行如下命令
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
#3.使用root登录mysql数据库
mysql -u root mysql
#4.更新root密码
mysql> UPDATE user SET authentication_string = password ( ‘new-password‘ ) WHERE User = ‘root‘ ;
#5.刷新权限
mysql> FLUSH PRIVILEGES;
#6.退出mysql
mysql> quit
#7.重启mysql
/etc/init.d/mysqld restart
#8.使用root用户重新登录mysql
mysql -uroot -p
Enter password: <输入新设的密码newpassword>
--当修改密码时提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
需要修改validate_password_policy的值:
mysql> set global validate_password_policy=0;
再查看
mysql> select @@validate_password_length;
--当卸载mysql提示error reading information on service mysqld: Invalid argument
可使用命令:rpm -e --nopreun --nopostun --nodeps
mac mysql error You must reset your password using ALTER USER statement before executing this statement.
安装完mysql 之后,登陆以后,不管运行任何命令,总是提示这个
step 1: SET PASSWORD = PASSWORD(‘your new password‘);
step 2: ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;
step 3: flush privileges;