MySQL报“Access denied for user 'root'@'%' to database”错误的解决方法
执行 GRANT ALL PRIVILEGES ON test
.* TO 'test_user'@'%' WITH GRANT OPTION 报错;
错误原因
user表中 'root'@'%'
没有grant的权限
解决方法
- **修改grant权限**
```
update mysql.user set Grant_priv='Y',Super_priv='Y' where user = 'root' and host = '%';
flush privileges;
```
- **重启服务,务必重启**
```
systemctl restart mysqld.service
# 或
service mysqld restart
```