完成。
MariaDB 开启远程连接
在数据库mysql 中的user表中可以看到默认是只能本地连接的,所有可以添加一个用户
备注:一定要输入完sql语句后加上分号(;),否则sql是未执行状态,配置无效。
# 针对ip
create user 'root'@'192.168.10.10' identified by 'password';
#全部
create user 'root'@'%' identified by 'password';
授权用户:
# 给用户最大权限
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
# 给部分权限(test 数据库)
grant all privileges on test.* to 'root'@'%' identified by 'password' with grant option;
# 刷新权限表
flush privileges;
# show grants for 'root'@'localhost';
grant all privileges on test.* to ‘root’@’localhost’ identified by “abcde” with grant option;//
WITH GRANT OPTION 这个选项表示该用户可以将自己拥有的权限授权给别人。
注意:经常有人在创建操作用户的时候不指定WITH GRANT OPTION选项导致后来该用户不能使用GRANT命令创建用户或者给其它用户授权。