Centos7解决数据库出现Access denied for user ‘root‘@‘%to database ‘xxx‘ 问题
原因: root@%表示 root用户 通过任意其他端访问操作 被拒绝! 授权即可:
1:进入数据库 mysql -u root -p
2.输入 mysql>grant all privileges on *.* to 'root'@'%' with grant option;
grant all privileges on *.* to 'root'@'%' with grant option;
3.输入flush privileges;
mysql> flush privileges;
4.重启mysql服务器,亲测重启很重要!!!
service mysql restart
或者先关闭再打开
[root@192 ~]# systemctl stop mysqld
[root@192 ~]# systemctl start mysqld
ps.另外很多服务器连不上的原因先检查防火墙状态!
!配置防火墙的命令!
1)启动、重启、关闭防火墙服务
# 启动
systemctl start firewalld
# 重启
systemctl restart firewalld
# 关闭
systemctl stop firewalld
#查看状态
systemctl status firewalld