在这里写一下,方便以后用
下面是找的别人的解决方式,我是用yum安装的,可能会和大神们的有所不同,后面都有注释,最下面还有我操作的正确的步骤和显示的信息,这个解决方式应该算比较友好了。实在不行的童鞋,教你绝招,先卸载干净再装一次,卸载干净很重要的,具体的问搜索引擎去
# /etc/init.d/mysql stop ----------------1 安装位置不一样下面我停止mysql的方式也不一样,我用的是yum安装的,要用/etc/rc.d/init.d/mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & --照做 2
# mysql -u root mysql --3
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; --4
mysql> FLUSH PRIVILEGES; --5
mysql> quit --6
# /etc/init.d/mysql restart --7 停止mysql的方式不一样,开启当然也不一样 我用/etc/init.d/mysqld start
# mysql -uroot -p --8这个都熟悉了,其实已经完成,以下都是测试了
Enter password: <输入新设的密码newpassword>
mysql>
具体步骤和所显示的信息
1.[root@root 桌面]# /etc/rc.d/init.d/mysqld stop
停止 mysqld: [确定]
2.[root@root 桌面]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 3353
[root@root 桌面]# 121125 01:36:08 mysqld_safe Logging to '/var/log/mysqld.log'.
121125 01:36:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
3.mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, 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.
4.mysql> update user set Password=PASSWORD('root') where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
5.mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
6.mysql> quit;
Bye
7.[root@root 桌面]# /etc/init.d/mysqld start
正在启动 mysqld: [确定]
8.[root@root 桌面]# mysql -u root -p
9.Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, 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>
到这开始欣喜吧………………
http://shaojiang216.blog.163.com/blog/static/1313258242012102515624945/