本文提供四种部署方式,请选择属于合适自己的方式
一.centos7 mysql5.7yum方式部署
1.准备工作:
关闭SELinux, 防火墙,修改主机名,解析主机名,时间同步
注意:先将本机的环境清干净
[root@mysql ~]# rpm -qa |grep mariadb
[root@mysql ~]# rpm -e mariadb-libs --nodeps
//查询到的所有mariadb的软件都要卸载掉
[root@mysql ~]# rm -rf /var/lib/mysql
[root@mysql ~]# rm -rf /etc/my.cnf
2.下载MySQL源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
[root@mysql ~]# yum repolist enabled | grep "mysql.*-community.*"
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
mysql-connectors-community/x86_64 MySQL Connectors Community 153
mysql-tools-community/x86_64 MySQL Tools Community 110
mysql57-community/x86_64 MySQL 5.7 Community Server 424
3.安装MySQL
[root@mysql ~]#yum -y install mysql-community-server
4.启动服务
首次启动服务时会在软件内部生成软件运行时需要的一些库和表,所以会比较慢
[root@mysql ~]# systemctl restart mysqld && systemctl enable mysqld
获取root用户的临时密码,并修改
[root@mysql ~]# grep "password" /var/log/mysqld.log
2020-05-28T04:02:51.535722Z 1 [Note] A temporary password is generated for root@localhost: 5!a664?L4DWy
5.修改root用户密码方法:
mysql -u root -p
mysql> set password for 'root'@'localhost'='Www.1.com';
mysql> flush privileges;
二.centos7mysql5.7rpm包部署
1.下载mysql-5.7.23-1.el7.x86_64.rpm-bundle-centos7.tar
下载地址:百度云
提取码:mm9h