MySQL中赋给用户远程权限

MySQL中grant all privileges on远程连接授权

记录MySQL远程连接所踩的坑

当你的帐号不允许从远程登陆,只能在localhost连接时。这个时候只要在mysql服务器上,更改 mysql 数据库里的 user 表里的 host 项,从localhost"改成%即可实现用户远程登录

授权法

MySQL 5.0+版本

mysql -u root -p

-- 给root账户授权(root默认只有本机访问的权限,要通过其他机器访问,必须授权)

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

-- 最后刷新数据库服务

flush privileges;

MySQL8.0版本不能按照grant all privileges on *.* to "root"@"%" identified by "xxxx";去修改用户权限,会报错

MySQL 8.0+版本

#先创建远程用户,再授权
create user 'root'@'%' identified by 'root';

grant all privileges on *.* to 'root'@'%' with grant option;

flush privileges;

注意授权后必须FLUSH PRIVILEGES;否则无法立即生效。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值