下载rpm包
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装mysql源
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
在线安装Mysql
yum -y install mysql-community-server
启动Mysql服务
systemctl start mysqld
设置开机启动
systemctl enable mysqld
systemctl daemon-reload
查看临时密码
cat /var/log/mysqld.log | grep password
修改root密码
备注 mysql5.7默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位)
mysqladmin -u root -p password ‘xHxing!123@’
设置允许远程登录
Mysql默认不允许远程登录,我们需要设置下,并且防火墙开放3306端口;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xHxing!123@' WITH GRANT OPTION;
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
编辑保存完 重启mysql服务
查看下编码:
mysql> show variables like '%character%';