GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
mysql默认情况下,只允许localhost连接,如果需要外部IP连接到mysql,需要向mysql数据库里的“user”表里添加相关授权。 例如:让newuser用户使用newpwd密码从IP:192.168.1.3主机链接到mysql服务器
具体步骤:
GRANT ALL PRIVILEGES ON . TO 'newuser'@'192.168.1.3' IDENTIFIED BY 'newpwd' WITH GRANT OPTION; mysql>flush privileges;
select * from mysql.user where user='root'\G
firewall-cmd --zone=public--add-port=3306/tcp --permanent
systemctl restart firewalld.service
firewall-cmd --list-ports