2.利用 kill 命令结束掉 mysqld 的进程;
3.使用--skip-grant-tables 参数启动 MySQL Server
shell>mysqld_safe --skip-grant-tables &
4.为设置新密码
shell>mysqladmin -u root flush-privileges password "newpassword"
5.重启 MySQL Server
mysql 修改密码
mysql 修改,可在 mysql 命令行执行如下:
mysql -u root mysql
mysql> Update user SET password=PASSWORD("new password") Where user=’name’;
mysql> FLUSH PRIVILEGES;
mysql> QUIT
教你如何将
MySQL 数据库的密码恢复
因为
MySQL 密码存储于数据库 mysql 中的 user 表中,所以只需要将我 windows 2003 下的
MySQL 中的 user 表拷贝过来覆盖掉就行了。
在
c:\mysql\data\mysql\(linux 则一般在/var/lib/mysql/mysql/)目录下有三个 user 表相关文件
user.frm、user.MYD、user.MYI
user.frm //user 表样式文件
user.MYD //user 表数据文件
user.MYI //user 表索引文件
为保险起见,三个都拷贝过来,不过其实如果之前在要恢复的那个
MySQL 上没有更改过
表结构的话,只要拷贝
user.MYD 就行了
然后
#. /etc/rc.d/init.d/mysql stop
#. /etc/rc.d/init.d/mysql start
#mysql -u root -p XXXXXX