[software development] MySQL8设置远程访问权限
Tofloor
poster avatar
191******22
deepin
2023-09-26 05:01
Author
#进入mysql
mysql -uroot -p

# 选择mysql
use mysql;

# 更新user表中的字段
update user set host='%'where user='root';

#刷新
flush privileges;

# 设置远程访问的权限 
grant all privileges on *.* to 'root'@'%' with grant option;

#刷新
flush privileges;
Reply Favorite View the author
All Replies
爱开发
deepin
2023-09-26 05:10
#1

这样不安全。其实可以不必这样的。使用 ssh -LN 将远程端口映射到本地即可。

Reply View the author
蔡EEPIN
deepin
2023-09-26 06:44
#2

不建议从mysql配置允许外网连接,端口转发是个好路子

Reply View the author
捕风
deepin
2023-09-26 18:33
#3
爱开发

这样不安全。其实可以不必这样的。使用 ssh -LN 将远程端口映射到本地即可。

细说下

Reply View the author
爱开发
deepin
2023-09-26 19:08
#4
捕风

细说下

# ssh -L 9999:example.org:80 -N -T username@remote_host
ssh -NL LocalPort:RemoteAddr:RemotePort [email protected]

ssh -NL 3307:example.org:3306 root@remote_ip -p remote_port

#
ssh -L 9999:example.org:80 -N -i ~/.ssh/id_rsa -p 2022 [email protected]

ssh -L 3307:127.0.0.1:3306 -N -i  ~/.ssh/id_rsa -p 2022 [email protected]

有些gui软件可以直接桥接的,比如 dbeaver

Reply View the author