记录一次修改mysql密码的完整过程(deepin系统)
登录数据库时出现:
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
在mysql 8.0版本的正确修改密码姿势为(deepin):
- 在my.cnf中添加skip-grant-tables
[mysqld]
skip-grant-tables
# 如果有[mysqld]便不用创建直接添加skip-grant-tables
# deepin my.cnf在/etc/mysql/
- 停止mysql服务
sudo systemctl restart mysql
- 进入到mysql之中,置空root密码,清除skip-grant-tables
xxxx@xxx:/xxx/xx$ mysql
mysql>use mysql;
# 清空root密码
mysql>update user set authentication_string=‘‘ where user=‘root‘;
mysql>quit
最后在my.cnf中清除skip-grant-tables
4. 修改root密码
xxxx@xxx:/xxx/xx$ mysql -uroot -p
# 直接回车
mysql>use mysql
#查看root的host地址
mysql> select user,host from user;
#如果为localhost使用下面语句(如果是其他只需替换@后面的字符串为你的目标地址)
#newpassword要求为数字+字符+符号的强密码组合(也可以试试其他大不了重来)
mysql>alter user ‘root‘@‘localhost‘ identified by ‘newpassword‘;
mysql>flush privileges;
mysql>quit
- 使用密码重新登陆
mysql -uroot -p #回车之后输入密码,不允许直接输密码了
# 记录一次修改mysql密码的完整过程(deepin系统)
标签:The cat 修改密码 要求 pre 允许 host 创建 deepin