mysql 重置密码

1、关闭mysql服务

```
service mysqld stop
```

2、skip-grant-tables 跳过权限验证,命令行启动mysql服务

mysqld_safe --user=mysql --skip-grant-tables --skip-networking&
或者
mysqld --skip-grant-tables

3、重开命令行,进入数据库,修改密码,刷新权限;

mysql -u root -p 

use mysql;

UPDATE user SET Password=PASSWORD('password') where USER='root';

FLUSH PRIVILEGES;

4、返回上一个命令窗口,结束第二步启动的mysql服务,重新启动mysql,即可

service mysqld start
  • 设置远程访问

使用密码进入mysql,然后授权mysql访问权限及密码,刷新权限

grant all privileges on *.* to root@"%" identified by "password";
FLUSH PRIVILEGES;
Categories: