FreeBSD 11 MySQL忘记密码解决方案

1、问题描述

    FreeBSD系统中MySQL是其他人安装,故按照忘记密码处理方式处理。

2、停止MySQL服务

    进入MySQL默认服务路径;

cd  /usr/local/etc/rc.d/

    停止MySQL服务

./mysql-server start|stop|restart

注意:其他方式杀死所有MySQL

killall -TERM mysqld  
3、跳过密码验证,直接登录MySQL
mysqld_safe --skip-grant-tables &
4、修改新密码,授权远程登录
USE mysql; -- 切换到 mysql DB
update user set authentication_string = password('password'), password_expired = 'N', password_last_changed = now() where user = 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;   授权
flush privileges;

注意:MySQL 5.7以后版本中 user表密码字段为:

authentication_string,之前版本为 password

猜你喜欢

转载自blog.csdn.net/smxzsp/article/details/79494698