MYSQL重置root密码(Access denied for user 'root'@'localhost' (using password: YES))
2016-08-29 17:03
549 查看
1.停止MYSQL服务;
在Ubuntu 或 Debian上sudo service mysql stop
或者
sudo /etc/init.d/mysql stop
在CentOS, Fedora, RHEL上:
sudo service mysqld stop
或者
sudo /etc/init.d/mysqld stop
2.进入安全模式
sudo mysqld_safe --skip-grant-tables &
PS:最后的
&符号是要有的
你可能会看到这样的信息:
mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect. mysqld_safe Logging to '/var/log/mysql/error.log'. mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
出现这些类似信息之后,你可以按
CTRL+C退出,然后进行下一步
NOTES:如果,我是说如果,没有报错请直接跳到第三步,在这你遇到报错
mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect. mysqld_safe Logging to '/var/log/mysql/error.log'. mysqld_safe A mysqld process already exists
请使用以下命令来确认mysql是否真的终止了
ps uaxww | grep -i mysql
一旦找到,就用
kill将进程终止,再重试一次
3.使用空密码登录
mysql -u root
4.使用mysql
数据库
use mysql;
你会看到这样的类似信息:
mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed
5.重新设置密码
update user set password=PASSWORD("yournewpassword") where User='root';
yournewpassword替换为你设置的密码
你大概会看到这些:
mysql> update user set password=PASSWORD("yournewpassword") where User='root';Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
6.重新设置权限
flush privileges;
如果出现以下熟悉的提示,基本上大功告成。
mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
7.退出
quit
8.重启MYSQL
在Ubuntu 或 Debian上sudo /etc/init.d/mysql stop
然后
sudo /etc/init.d/mysql start
在CentOS, Fedora, RHEL上:
sudo /etc/init.d/mysqld stop
然后
sudo /etc/init.d/mysqld start
9.重新登录
mysql -u root -p
输入刚刚设置的密码。DONE
相关文章推荐
- mysql忘记密码了1045,解决MySql 数据库 提示:1045 access denied for user 'root'@'localhost' using password yes
- mysql修改密码后报错:ERROR 1045:Access denied for user:'root@localhost'(using password:YES)
- MySQL改密码报错:ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)
- MySql错误1045 Access denied for user 'root'@'localhost' (using password:YES) windows下的解决方案(忘记密码)
- MySql错误1045 Access denied for user 'root'@'localhost' (using password:YES) windows下的解决方案(忘记密码)
- Mysql连接错误:Access denied for user 'root'@'localhost' (using password:YES)解决方案以及WINDOWS下修改Mysql密码
- mysql update完root用户密码后,再登陆报错”Access denied for user 'root'@'localhost' (using password: YES)“的解决方法
- mysql 重新修改密码 以及ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)问题解决
- mysql启动问题access denied for user 'root'@'localhost'(using password:YES)
- windows mysql提示:1045 access denied for user 'root'@'localhost' using password yes 解决方案
- mysql登录:access denied for user 'root@localhost'(using password: YES)
- 【数据库】mysql(1045 access denied for user 'root'@'localhost' using password yes)的解决方案
- mysql修改密码后phpmyadmin 出现#1045 - Access denied for user 'root'@'localhost' (using password: NO)
- mysql Access denied for user 'root'@'localhost' (using password: YES)
- MySQL问题 Access denied for user 'root'@'localhost' (using password: YES)
- linux下连接windows mysql的错误:Access denied for user 'root'@'localhost' (using password: YES)
- mysql启动问题access denied for user 'root'@'localhost'(using password:YES)
- mysql access denied for user'root'@'localhost' using password yes
- mysql报错 Access denied for user 'root'@'localhost' (using password: YES)
- MySQL 出现 Access denied for user 'root'@'localhost' (using password: YES) 错误