文章正文

MYSQL添加远程用户或允许远程访问三种方法

【文档】2020-04-23

简介MYSQL添加远程用户或允许远程访问三种方法

方式一:

用root用户登陆,然后:

grant all privileges on *.* to 创建的用户名 @"%" identified by "密码";

flush privileges;   

格式:

grant 权限 on 数据库教程名.表名 to 用户@登录主机 identified by "用户密码";

@ 后面是访问MySQL的客户端ip地址或主机名 % 代表任意的客户端, localhost 为本地访问

设置用户是否具有远程访问权限。如下:

use mysql;

update db set host = '%' where user = '用户名'; (如果写成 host=localhost 那此用户就不具有远程访问权限)

flush privileges;

grant all privileges on *.* to 'myuser'@'%' identified by 'mypassword' with grant option;

方式二:

1.  用root用户登录

添加一个用户admin并授权通过本地机localhost)访问,密码"something"

mysql>grant all privileges on *.* to admin@localhost identified by 'something' with grant option;

添加一个用户admin并授权可从任何其它主机发起的访问(通配符%)

 mysql>grant all privileges on *.* to admin@"%" identified by 'something' with grant option;

2.使用insert语句:

mysql>insert into user values('%','admin',password('something'), 'y','y','y','y','y','y','y','y','y','y','y','y','y','y')

用户信息可在mysql数据库中的users表中查看。

方式三:

添加远程用户admin密码为password 

grant all privileges on *.* to admin@localhost identified by 'password' with grant option 

grant all privileges on *.* to admin@"%" identified by 'password' with grant option

打赏支持

感谢您的支持,加油!

打开微信扫码打赏,你说多少就多少

找书费时,联系客服快速获取!

扫码支持

在线客服8:30-22:30,若离线请留言!

获取教程,请联系在线客服!

扫码支持

在线客服8:30-22:30,若离线请留言!

热门阅读

找PDF电子书,太费时间?

  • 微信扫描二维码,让客服快速查找。
  • 在线客服8:30-22:00,若离线请留言!