Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5376420
  • 博文数量: 890
  • 博客积分: 12876
  • 博客等级: 上将
  • 技术积分: 10760
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-04 14:18
个人简介

猝然临之而不惊,无故加之而不怒。

文章分类

全部博文(890)

文章存档

2016年(1)

2014年(18)

2013年(41)

2012年(48)

2011年(65)

2010年(84)

2009年(121)

2008年(101)

2007年(129)

2006年(95)

2005年(118)

2004年(69)

分类: Mysql/postgreSQL

2013-04-26 14:26:15

From:

 #有的时候我们因为一些原因需要重新设置root密码,我做了一下尝试,记录下步骤,供有序要得朋友们参考。
[root@CactiEZ ~]# mysql -u root -p        #尝试登录mysql
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)        #因密码不正确登录失败
[root@CactiEZ ~]# service mysqld stop        #停止mysqld
Stopping mysqld:                                           [  OK  ]
You have new mail in /var/spool/mail/root
[root@CactiEZ ~]# mysqld_safe --skip-grant-tables&    #跳过权限表启动
[1] 20462
[root@CactiEZ ~]# 130326 14:01:10 mysqld_safe Logging to '/var/log/mysqld.log'.
130326 14:01:10 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
 
[root@CactiEZ ~]# mysql -u root    #以root身份登录mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.47 Source distribution
 
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> UPDATE
    -> mysql.user
    -> SET
    -> Password = password('yourpasswd')
    -> WHERE
    -> User = 'root';                                #更改root用户的密码
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3  Changed: 3  Warnings: 0
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> exit
Bye
[root@CactiEZ ~]# service mysqld restart        #将mysqld重新启动
130326 14:03:51 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-tables
[root@CactiEZ ~]# service mysqld start
Starting mysqld:                                           [  OK  ]
[root@CactiEZ ~]# mysql -u root -p                #使用新设置的密码登录
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.47 Source distribution
 
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql>                                                 #登录成功

阅读(1010) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~