Shutting down MySQL. [ OK ]
添加红色字体参数。
保存退出。
4:启动mysql 服务
[root@mysql5 bin]# /etc/init.d/mysql.server start
Starting MySQL. [ OK ]
5:进入mysql
[root@mysql5 bin]# ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.51-log 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>
此时是没有密码的直接回车下一步。
6: 进入到mysql 库中,修改root 密码,
mysql> use mysql
Database changed
mysql> update user set password='root' where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
7:退出,重启mysql 服务
[root@mysql5 bin]# /etc/init.d/mysql.server restart
Shutting down MySQL. [ OK ]
Starting MySQL. [ OK ]
8:利用新密码进入数据库
[root@mysql5 bin]# ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.51-log 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>
成功进入
(因为启动mysql 服务有多种方式,所以我们下面介绍第二种方式)
1:杀掉原来进行着的mysql
rcmysqld stop
或者:
service mysqld stop
或者:
kill -TERM mysqld
2:以命令行参数启动mysql
/usr/bin/mysqld_safe --skip-grant-tables &
3:修改管理员密码
use mysql;
update user set password=password('yournewpasswordhere') where user='root';
flush privileges;
exit;
4:杀死mysql,重启mysql