centos7.2安装mysql5.7
wet http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
会重定向到https链接,这时用wget下载不下来,可以先在浏览器中用上述链接下载,然后拷贝到/usr/tomcat5.7目录。
#安装 mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum install mysql-community-server
#启动mysql服务
systemctl start mysqld
#开机启动
systemctl enable mysqld
systemctl daemon-reload
#修改root默认的密码
grep 'temporary password' /var/log/mysqld.log
2018-08-13T01:48:20.617185Z 1 [Note] A temporary password is generated for root@localhost: kWa>Ilu=y3N.
# 先用默认密码登入root账号
set password for 'root'@'localhost'=password('12345678d');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
#会发现,我设置的密码不符合mysql的安全策略,mysql 5.7 默认开启了密码安全策略检查
#修改密码安全策略强度
在文件 /etc/my.cnf 末尾添加 validate_password_policy=0 (验证强度为low)
重启mysqld 服务使设置生效: systemctl restart mysqld
登入root 账号:设置新密码 set password for 'root'@'localhost'=password('12345678d');
#退出root账号后,就可以使用新密码登入了。
#运行root远程连接,默认情况下只允许root本地连接,改表法
use mysql;
update user set host='%' where user='root';
配置默认为utf-8编码
vi /etc/my.cnf
character_set_server=utf8
init_connect='SET NAMES utf8'