本文共 641 字,大约阅读时间需要 2 分钟。
今天在虚拟机上登录mysql 时提示Access denied for user 'root'@'localhost' (using password: YES),
下面分享下处理方法:
1. 关闭mysql 服务
[root@localhost ~]# service mysql stop
2. 不使用密码直接登录
[root@localhost ~]# sudo mysqld_safe --skip-grant-tables &
3. 然后执行mysql 直接登录
[root@localhost ~]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g....Your MySQL connection id is 1Server version: 5.6.30-1 (Debian)Copyright (c) 2000, 2016, Oracle and/or its affiliates.Mysql>
4. 进入数据库后,切换到mysql 数据库
mysql> use mysql;
5. 切换数据库后, 执行修改密码指令
mysql> update user set password = password('新的密码') where user = 'root';
6. 启动mysql 服务,再使用新密码登录
[root@localhost ~]# service mysql start
转载地址:http://ztqvi.baihongyu.com/