mysql远程连接命令(win10远程桌面黑屏解决办法)
CREATE USER ”admin’@’%’ IDENTIFIED BY ‘password’;
mysql安装后默认是localhost访问,如果需要外部访问可以设置一个新的账号把host改为%,意味着所有ip均可以访问
GRANT ALL PRIVILEGES ON *.* TO ‘admin’@’%’WITH GRANT OPTION;
FLUSH PRIVILEGES;
mysql查看其开放的端口
登录Mysql后,查看当前端口show global variables like ‘port’;
如果要更改mysql开放的端口,vim /etc/my.cnf,修改port,如果文件中有bind-address = 127.0.0.1则需要注掉,不然mysql只能被远端机自身访问。
firewall-cmd命令
# firewall-cmd –list-all-zones #查看所有的zone信息
# firewall-cmd –get-default-zone #查看默认zone是哪一个
# firewall-cmd –zone=internal –change-zone=p3p1 #临时修改接口p3p1所属的zone为internal
# firewall-cmd –add-service=http #暂时开放http
# firewall-cmd –permanent –add-service=http #永久开放http
# firewall-cmd –zone=public –add-port=80/tcp –permanent #在public中永久开放80端口
# firewall-cmd –permanent –zone=public –remove-service=ssh #从public zone中移除服务
# firewall-cmd –reload #重新加载配置
查看3306端口打开状态
firewall-cmd –add-port=3306/tcp –permanent
远程链接mysql:
mysql -u admin -h 192.168.123.123 -p
发表评论