mysql的root忘记,现无法操作数据库
停止mysql服务service mysql stop
然后使用如下的参数启动mysql, --skip-grant-tables会跳过mysql的授权
shell#/usr/bin/mysqld_safe --skip-grant-tables &
mysql -p 回车,进入不需要密码
mysql>
mysql>update mysql.user set Password=password('123456') where User='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
重启mysql