mysql>show variables like '%character%’;
可以看到database和server编码都为latin1,我们修改为utf8
#1.将my-default.cnf 拷贝到 /etc/my.cnf
cp /usr/share/doc/mysql/my-default.cnf /etc/my.cnf
#2.编辑/usr/my.cnf在[client](如果没有就自己加)下增加
default-character-set = utf8
#3.编辑/usr/my.cnf在[mysqld]下增加
character_set_server = utf8
#4.重启MySql服务
systemctl restart mysql.service
#5.重现连接mysql并查看编码如下:
mysql -uroot –proot
mysql>show variables like '%character%’;
允许远程登录
授权格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";
1.mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
2.mysql>FLUSH PRIVILEGES;
开放3306端口
1.firewall-cmd --zone=public --add-port=3306/tcp --permanent
2.firewall-cmd --reload