0%

centos7.* 安装 mysql 7

centos7.* 安装 mysql 7的方法

yum安装方式

1. 下载mysql源安装包

wget http://dev.mysql.com/get/  mysql57-community-release-el7-8.noarch.rpm

2. 安装mysql源

yum localinstall mysql57-community-release-el7-8.noarch.rpm

3.安装mysql

yum install mysql-community-server

4.设置开机启动

systemctl enable mysqld
systemctl daemon-reload

5.修改root本地登录密码

图片中红色框框中就是mysql随机生成的密码,复制到Enter password处即可登录

grep “temporary password” /var/log/mysqld.log

linux-centos7-install-mysql7-2020510135213

登录后修改mysql本地root密码

mysql> ALTER USER "root"@"localhost" IDENTIFIED BY "MyNewPassword1!"; 

或者

mysql> set password for "root"@"localhost"=password("MyNewPassword1!"); 

注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误

6.添加远程登录用户

为了账户安全起见建议新建账户用于远程登录,root权限过高(本地登录)

mysql> GRANT ALL PRIVILEGES ON *.* TO "xinyonghu"@"%" IDENTIFIED BY "XinYongHu123!" WITH GRANT OPTION;

7.配置默认编码为utf8

修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置

1
2
3
[mysqld]
character_set_server=utf8
init_connect="SET NAMES utf8"

参考 CentOS7 64位下MySQL5.7安装与配置(YUM)

源代码编译安装

等待编写中……