方法原理与mariadb相同
登陆mysql
mysql -u root -p
设置访问权限
如果允许用户root从ip为192.168.1.123的主机连接到mysql服务器
并使用root作为密码
grant all privileges on *.* to 'root'@'192.168.1.123'identified by 'password' with grant option;
或者
grant all privileges on *.* to 'root'@'%' identified by 'abcd1234' with grant option;
abcd1234是你要设置的密码
’%'代表所有ip
刷新权限
flush privileges;
查看访问权限
select user, host from mysql.user;
另外说明
1.使用宝塔面板可以在面板后台进行设置。
2.远程访问需要在mysql所在服务器的防火墙开放3306端口。
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论