Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6097603
  • 博文数量: 2759
  • 博客积分: 1021
  • 博客等级: 中士
  • 技术积分: 4091
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-11 14:14
文章分类

全部博文(2759)

文章存档

2019年(1)

2017年(84)

2016年(196)

2015年(204)

2014年(636)

2013年(1176)

2012年(463)

分类: 系统运维

2013-09-14 11:23:48

linux下mysql的root密码忘记解决方


1. vi /etc/my.cnf 
在[mysqld]的段中加上一句:skip-grant-tables

2.重新启动mysqld 

3.登陆修改密码
/usr/bin/mysql -uroot -p
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 3 to server version: 3.23.56 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
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 
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ; 
Query OK, 0 rows affected (0.00 sec) 
Rows matched: 2 Changed: 0 Warnings: 0 
mysql> flush privileges ; 
Query OK, 0 rows affected (0.01 sec) 
mysql> quit 
Bye

4.vi /etc/my.cnf 
将刚才在[mysqld]的段中加上的skip-grant-tables删除 

5.重启mysql
阅读(466) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~