在這裏寫一下,方便以後用
下面是找的別人的解決方式,我是用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/