【问题】

mariadb(MySql)安装之后,本地连接mysql是可以的,但是远程的机器不能连接和访问。

【解决】

修改mysql远程连接的ip限制配置。

【步骤】

1.本地mysql客户端连接mysql

mysql -u root -p

2.执行sql语句:

新安装的数据库 可以设置  /etc/my.cnf        skip-grant-tables=1(跳过密码验证)

--使用mysql系统数据库

use mysql;

--配置192.168.1.10可以通过root:123456访问数据库

GRANT ALL PRIVILEGES ON *.* to 'root'@'192.168.1.10' identified by '';
//grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

--从mysql数据库中的授权表重新载入权限

flush privileges;

--查看用户权限是否变更

select * from user;

修改密码

update user set password=PASSWORD('') where user='root';
update user set authentication_string = password(''),password_expired = 'N', password_last_changed = now() where user = 'root';(新版本)

3.至此,远程访问权限已经配置完成。

先看 mysql 服务有没有启动

systemctl start mariadb

再看防火墙有没有阻拦

systemctl stop firewalld

mysql设置远程访问权限