Chinaunix首页 | 论坛 | 博客
  • 博客访问: 224664
  • 博文数量: 35
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 938
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-12 14:52
文章分类

全部博文(35)

文章存档

2016年(4)

2015年(5)

2014年(16)

2013年(10)

我的朋友

分类: 系统运维

2013-09-12 16:01:22

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
阅读(2751) | 评论(1) | 转发(2) |
给主人留下些什么吧!~~

7大爷2013-09-13 09:10:28

不错不错