没有记住MySQL数据库root用户默认密码(为初始化安装mysql时默认生成)
1)修改/etc/my.cnf文件,在[mysqld]的段中加上一句:skip-grant-tables
重启mysql服务
[root@localhost ~]# service mysqld restart
2)以无密码方式进入mysql:
[root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: 直接回车
mysql>use mysql
输出:Database changed
mysql> update user set authentication_string='' where user='root';
3)重置密码后再将/etc/my.cnf文件中添加的“skip-grant-tables”注释掉
重启mysql服务
[root@localhost ~]# service mysqld restart
[root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password