wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm 下载mysql源安装包
yum localinstall mysql57-community-release-el7-8.noarch.rpm 安装mysql源
yum repolist enabled | grep "mysql.-community." 检查mysql源是否安装成功,看到下图表示安装成功
修改mysql版本
vim /etc/yum.repos.d/mysql-community.repo 把enabled=0改为1既安装对应的版本,不安装的要改为0
yum install mysql-community-server 安装mysql
systemctl status mysqld 启动mysql服务
systemctl enable mysqld systemctl daemon-reload 开机启动
grep 'temporary password' /var/log/mysqld.log 查看root密码
mysqld.log为空时打开vim /etc/my.cnf文件添加
skip-grant-tables 来忽略密码 进入mysql之后再设置新的密码
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
或者
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');
修改密码策略
在/etc/my.cnf文件添加validate_password_policy配置,指定密码策略
选择0(LOW),1(MEDIUM),2(STRONG)其中一种,选择2需要提供密码字典文件 validate_password_policy=0
如果不需要密码策略,添加my.cnf文件中添加如下配置禁用即可:
validate_password = off
重新启动mysql服务使配置生效:
systemctl restart mysqld
添加远程登录用户
GRANT ALL PRIVILEGES ON . TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917!' WITH GRANT OPTION;
配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
网友评论