mysql创建远程连接_mysql 添加远程访问

第一种:mysql 5.0(两种方式)

一、

在命令窗口输入,mysql -u root -p  回车,并输入密码

执行 use mysql

执行下面句子,查看权限,root默认权限为localhost

select user,host from user;

更改root权限为%

update user set host = '%' where user = 'root';

刷新

flush privileges;

二、

在命令窗口输入,mysql -u root -p  回车,并输入密码

执行 use mysql

设置test为账户,密码为:ceshipwd,权限为%,所有人

grant all on *.*  to 'test'@'%' identified by 'ceshipwd';

如果权限不设置为所有人,可设定固定访问IP如下:

grant all on *.*  to 'test'@'111.111.111.111' identified by 'ceshipwd';

最后,刷新

flush privileges;

第一种:mysql 8.0以上(两种方式)

一、

在命令窗口输入,mysql -u root -p  回车,并输入密码

执行 use mysql

执行下面句子,查看权限,root默认权限为localhost

select user,host from user;

更改root权限为%

update user set host = '%' where user = 'root';

刷新

flush privileges;

二、

在命令窗口输入,mysql -u root -p  回车,并输入密码

执行 use mysql

设置test为账户,密码为:ceshipwd,权限为%,所有人

先建立账号:

create user 'test'@'%' identified with mysql_native_password by 'ceshipwd';

再添加账号权限

grant all on *.*  to 'test'@'%';

如果权限不设置为所有人,可设定固定访问IP如下:

grant all on *.*  to 'test'@'111.111.111.111';

最后,刷新

flush privileges;

三、

各版本修改密码的格式:

mysql5.0格式如下:

本地可以访问

alter user 'ceshi'@'localhost' identified   by 'ceshipw';

所有都可以访问

alter user 'ceshi'@'%' identified   by 'ceshipw';

mysql8.0以上格式如下:

本地可以访问

alter user 'ceshi'@'localhost' identified with mysql_native_password  by 'ceshipw';

所有都可以访问

alter user 'ceshi'@'%' identified  with mysql_native_password by 'ceshipw';

*使用navicat连接mysql8.0数据库时,提示1251-client does not support authentication protocol requested by server;consider upgrading mysql client 解决办法:

进入数据库,更新一下认证格式

user mysql;

#下面方式是修改密码的格式,即可正常访问

alter user 'ceshi'@'%' identified with mysql_native_password by 'ceshipw';

flush privileges;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值