1、下载mysql
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2、yum安装
yum -y install mysql57-community-release-el7-10.noarch.rpm
3、安装MySQL服务器
yum -y install mysql-community-server
4、启动mysql
systemctl start mysqld.service
5、查看状态
systemctl status mysqld.service
6、查看密码并修改
grep "password" /var/log/mysqld.log
root@localhost:后边的几位是密码
#进入数据库
mysql -uroot -p
#修改密码 注意:密码设置必须要大小写字母数字和特殊符号(,/';:等)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
7、开启mysql的远程访问
注意 % 代表所有
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
flush privileges;
exit
8、开启端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
#重启防火墙
firewall-cmd --reload
9、修改编码
退出mysql 进入etc目录下my.cnf
vim /etc/my.cnf
#添加
[client]
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
#重启mysql
systemctl restart mysqld.service