mysql忘记密码解决方法
修改mysql的配置文件my.cnf
my.cnf配置文件的位置,一般在/etc/my.cnf,有些版本在/etc/mysql/my.cnf
在配置文件中,增加2行代码
[mysqld] skip-grant-tables
作用是登录mysql的时候跳过密码验证
然后启动mysql服务,并进入mysql

修改密码
连接mysql这个数据库,修改用户密码
mysql> use mysql;
Database changed
mysql> update mysql.user set authentication_string=password('root_password') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit

浙公网安备 33010602011771号