etc/init.d/mysql stop (停止mysql)
/usr/bin/mysqld_safe --skip-grant-tables
另外打开个SSH连接窗口
[root@localhost ~]# mysql
insert into mysql.user (host, user, password) values ('localhost', '账号一般是root', password('你设置的密码'));
flush privileges;
grant all on *.* to 'root'@'localhost';