如果忘记了mysql的root密码,可以用以下方法解决。 1.先关闭msyql,用如下方法启动msyql
[iyunv@tvmyunying ~]#service mysqld stop [iyunv@tvmyunying ~]# /usr/bin/mysqld_safe --skip-grant-tables & --skip-grant-tables 不使用任何数据库信息去访问 2.更新root用户密码
[iyunv@tvmyunying ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.61 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;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
mysql> update user set password=password("12345678") where user="root";
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
3.重启数据库
[iyunv@tvmyunying ~]#service mysqld restart
|