# 重置密码
```bash
vim /etc/my.cnf
```
加上一条: `--skip-grant-tables`保存并退出
```bash
mysql -u -p
```
直接敲回车不用密码直接进入
```bash
use mysql
update user set authentication_string=password('root') where user='root';
```
修改root默认密码
# 外网访问
## 1.配置防火墙,3306端口
## 2.给mysql用户授权外网访问权限
```bash
mysql -u root -p
select user,host from user;
update user set host='%' where user='root'
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
```