centos 7 上通过 yum 安装 mysql 5.7

前端之家收集整理的这篇文章主要介绍了centos 7 上通过 yum 安装 mysql 5.7前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
1. 获取 yum 源
wget http://repo.MysqL.com/MysqL57-community-release-el7-9.noarch.rpm
yum install MysqL57-community-release-el7-9.noarch.rpm
查看yum源
yum list MysqL-community-server
2. 安装
yum install MysqL-community-server
3. 配置 systemd
[root@six lzo]# cat /etc/systemd/system/MysqL.service
[Unit]
Description=MysqL Server
After=network.target


[Service]
ExecStart=/usr/sbin/MysqLd --defaults-file=/data/MysqLd/my.cnf --datadir=/data/MysqL --socket=/data/MysqLd/MysqLd.sock --user=MysqL
Group=MysqL
WorkingDirectory=/usr


[Install]
WantedBy=multi-user.target


4. 配置 MysqL
[root@six lzo]# mkdir /data/MysqL;mkdir /data/MysqLd/
[root@six lzo]# chown -R MysqL:MysqL /data/MysqL;chown -R MysqL:MysqL /data/MysqLd/
[root@six lzo]# chown -R MysqL:MysqL /data/MysqL;chown -R MysqL:MysqL /data/MysqLd/
注意,原来的 MysqL_install_db 已经废弃不用
[root@six lzo]#/usr/sbin/MysqLd --initialize --defaults-file=/data/MysqLd/my.cnf --datadir=/data/MysqL --user=MysqL
[root@six lzo]# chown -R MysqL:MysqL /data/MysqL;chown -R MysqL:MysqL /data/MysqLd/


5. 配置my.cnf
[root@six lzo]# mv /etc/my.cnf /data/MysqLd/my.cnf
[root@six lzo]# chown -R MysqL:MysqL /data/MysqLd
修改 /data/MysqLd/my.cnf内的内容,主要是 MysqLd节点
datadir=/data/MysqL
socket=/data/MysqLd/MysqL.sock
skip-grant-tables
default-time-zone='+8:00'
log_timestamps='system'
explicit_defaults_for_timestamp
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/data/MysqLd/MysqLd.log
pid-file=/data/MysqLd/MysqLd.pid


6. 配置 MysqL 用户
[root@six lzo]# systemctl start MysqL.service
[root@six lzo]# MysqL -S/data/MysqLd/MysqLd.sock
MysqL shell 中增加用户
MysqL> FLUSH PRIVILEGES;
MysqL> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1122334455' WITH GRANT OPTION;
MysqL> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '1122334455' WITH GRANT OPTION;
MysqL> FLUSH PRIVILEGES;
MysqL> \q


7. 复位权限
注释 /data/MysqLd/my.cnf内,skip-grant-tables,例如:
#skip-grant-tables

[root@six lzo]# systemctl restart MysqL.service


8. 验证安装

[root@six lzo]# rpm -aq|grep "MysqL" MysqL-community-libs-5.7.15-1.el7.x86_64 MysqL57-community-release-el7-9.noarch MysqL-community-client-5.7.15-1.el7.x86_64 MysqL-community-server-5.7.15-1.el7.x86_64 MysqL-community-common-5.7.15-1.el7.x86_64

[root@six lzo]# MysqL -S/data/MysqLd/MysqLd.sock -uroot -p 输入 1122334455,登录完成,整个安装完成

猜你在找的CentOS相关文章