#####1,到http://dev.mysql.com/downloads/repo/yum/下载yum源 wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm #####2,安装yum源,替换系统默认的MysqL源 yum localinstall MysqL57-community-release-el7-11.noarch.rpm #####3,验证MysqL源是否添加成功 yum repolist enabled | grep "MysqL.-community." #####4,查看所有MysqL的发行版本列表 yum repolist all | grep MysqL #####5,禁用5.7,安装5.6执行如下命令 yum-config-manager --disable MysqL57-community yum-config-manager --enable MysqL56-community #####6,步骤5也可以编辑/etc/yum.repos.d/MysqL-community.repo文件,达到启用禁用 默认5.7的文件 [MysqL57-community] name=MysqL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 修改成5.6的 # Enable to use MysqL 5.6 [MysqL56-community] name=MysqL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
最后执行repolist enabled | grep MysqL是修改生效
#####7,安装MysqL yum install MysqL-community-server 注意:同时也安装了MysqL-community-client,MysqL-community-common,MysqL-community-libs这三个组件 #####8,启动MysqL服务 service MysqLd start #####9,检查MysqL服务状态 service MysqLd status #####10,MysqL初始化时会生成一个临时密码(Pr,KL=?ab7y/),密码为 grep 'temporary password' /var/log/MysqLd.log #####11,修改密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'RestyleTest@2017'; 注意:密码要包含一个大写字符,一个小写字符,数字,特殊字符,不少于8位. #####12,授权root用户可以远程登录访问 GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY '新的密码' WITH GRANT OPTION; FLUSH PRIVILEGES; #####13,查看默认编码 show variables like '%character%'; #####14,配置默认编码为utf8 vi /etc/my.cnf [MysqLd] character_set_server=utf8 init_connect='SET NAMES utf8' #####15,重启MysqL服务 systemctl restart MysqLd #####16,关闭防火墙或禁用防火墙对3306端口的拦截 vi /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT service iptables restart