yum安装mysql
1、添加mysql_yum_repository
登陆https://dev.mysql.com/downloads/repo/yum/,下载相关repository.rpm
(需要mysql账号)
也可以使用wget直接下载
wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
2、将mysql_yum_repository添加到yum源配置文件中
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
安装完毕后,查看相关repo文件
cat /etc/yum.repos.d/mysql-community.repo |mysql-community-source.repo
3、更新yum源数据
yum clean all
yum makecache
#### 4、安装相应mysql版本
yum -y install mysql-community-server.x86_64
5、启动mysql
systemctl start mysqld
systemctl enable mysqld
6、初始化mysql密码
查看随机mysql密码
grep password /var/log/mysqld.log
mysql -uroot -p
输入临时密码
更新mysql登陆密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password';
mysql官方密码策略
https://dev.mysql.com/doc/refman/5.7/en/password-management.html
关闭密码策略
cat /etc/my.cnf
7、添加中文字符集
cat /etc/my.cnf
重启mysqld服务,使得配置文件生效
mysql官方DOC:https://dev.mysql.com/doc/refman/5.7/en/