CentOS 7安装 MySQL 5.7

1. 配置DNS

#显示当前网络连接
#nmcli connection show
NAME UUID TYPE DEVICE
eno1 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eno1

#修改当前网络连接对应的DNS服务器,这里的网络连接可以用名称或者UUID来标识
#nmcli con mod ens160 ipv4.dns "114.114.114.114 8.8.8.8"

#将dns配置生效
#nmcli con up ens160

2. 安装wget

3. 修改CentOS默认yum源为mirrors.aliyun.com

#备份系统自带yum源配置文件
#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

#下载ailiyun的yum源配置文件到/etc/yum.repos.d/
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#运行yum makecache生成缓存
#yum makecache

#更新系统就会看到以下mirrors.aliyun.com信息
#yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com

  

4. 安装MySQL

#添加 MySQL Yum源
#在 http://dev.mysql.com/downloads/repo/yum/ 选择CentOS 7对应的yum包并下载

#安装软件源
#rpm -Uvh mysql80-community-release-el7-1.noarch.rpm

#安装yum-config-manager
#yum -y install yum-utils

#选择5.7 release
#yum-config-manager --disable mysql80-community
#yum-config-manager --enable mysql57-community

#安装MySQL服务端
#yum install -y mysql-community-server

#启动MySQL
#systemctl start mysqld.service

#检查MySQL运行状态
#systemctl status mysqld.service

#获取MySQQL临时密码
#grep 'temporary password' /var/log/mysqld.log
[Note] A temporary password is generated for root@localhost: phZ*pu%rP6d#

#登录并修改密码
#mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Pwd123456!';

#授权其他机器登录
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Pwd123456!' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

相关推荐