mariadb新安装解决远程访问以及root登录

mariadb新安装解决远程访问以及root登录
一、修改/etc/mysql/my.conf
找到bind-address = 127.0.0.1这一行
直接#掉或者改为bind-address = 0.0.0.0即可

二、为需要远程登录的用户赋予权限
1、新建用户远程连接mysql数据库
grant all on *.* to admin@'%' identified by '123456' with grant option;
flush privileges;
允许任何ip地址(%表示允许任何ip地址)的电脑用admin帐户和密码(123456)来访问这个mysql server。
注意admin账户不一定要存在。

2、支持root用户允许远程连接mysql数据库
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;

三、打开root插件访问模式
mariadb默认本地登录不需要密码,如果要使用root用户进行登录,执行
select host,user,plugin from user;
可看到root用户的plugin为unix_socket,执行修改
update user set plugin='mysql_native_password' where User='root';
flush privileges;

posted on 2019-09-06 16:31  剩余价值  阅读(11243)  评论(0编辑  收藏  举报

导航