[root@testlinux ~]# mysqladmin -u root password mysql
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user
'root'@'localhost'
(using password:
NO)'
出现这种提示表明无法修改密码...那究竟如何才能修改密码...
以下介绍的方法...修改roota密码....即使root密码忘了 也适用。。。。
step1:停止mysql服务
step2:启动mysqld服务,加上--skip-grant-tables选项
step3:用root用户连接mysql(这时不用输入密码即可进入)
step4:为root用户设置新密码
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("hello")where user="root";
Query OK, 3 rows affected (0.03
sec)
Rows matched: 3
Changed: 3 Warnings: 0
mysql> flush
privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
quit
step5:重启mysql服务
OK...现在用root连接你会发现密码已经改过来了。。^_^