系统环境:centos
操作方法:
1.杀掉mysql进程
方法1、[root@localhost /]#killall mysqld
方法2、[root@localhost /]#ps -aux //查看所有进程,找到mysql进程的pid
然后
[root@localhost /]#kill pid //pid是mysql的进程号
2.用--skip-grant-tables参数启动mysqld
[root@localhost /]#/usr/local/mysql/bin/mysqld_safe --skip-grant-tables&
// 其中/usr..../bin是我的mysql安装目录
[root@localhost /]#/usr/local/mysql/bin/
[root@localhost /]# ./mysql
eg:
[root@localhost bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.60-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
是否看到了希望??呵呵
mysql> use mysql //切换到mysql database
mysql> UPDATE user SET password=password('123456') WHERE user='root';
//将root密码该为123456了
搞定!