文章目录
- 环境准备
- 配置Yum Repository
-
- 下载Yum Repository RPM
- 安装Yum Repository RPM
- 指定要安装的版本
- 禁用最新版本
- 启用要安装的版本
- 查看
- 安装
- 启动mysql
- 密码
环境准备
- 操作系统(CentOS7)
[[email protected] opt]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core)
- 安装yum-utils
yum -y install yum-utils
- 安装wget
[[email protected] opt]# yum -y install wget
配置Yum Repository
下载Yum Repository RPM
- A 在官网找到对应系统的Yum Repository RPM包并下载。然后上传到服务器。
Centos7安装Mysql5.7环境准备配置Yum Repository安装启动mysql密码 - B 或直接在服务器下通过命令下载。
[[email protected] opt]# wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
安装Yum Repository RPM
[[email protected] opt]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:mysql80-community-release-el7-3 ################################# [100%]
指定要安装的版本
禁用最新版本
[root@localhost opt]# yum-config-manager --disable mysql80-community
启用要安装的版本
[roo[email protected] opt]# yum-config-manager --enable mysql57-community
查看
[[email protected] opt]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community disabled
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - disabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 108
mysql-connectors-community-source MySQL Connectors Community - disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 90
mysql-tools-community-source MySQL Tools Community - Sourc disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 347
mysql57-community-source MySQL 5.7 Community Server - disabled
mysql80-community/x86_64 MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - disabled
[[email protected] opt]#
安装
[[email protected] opt]# yum install mysql-community-server
Loaded plugins: fastestmirror
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql57-community | 2.5 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: ap.stykers.moe
* extras: centos.ustc.edu.cn
* updates: ap.stykers.moe
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.26-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.26-1.el7 for package: mysql-community-server-5.7.26-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.26-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.26-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.26-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.26-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.26-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================
Package Arch Version Repository Size
=======================================================================================================
Installing:
mysql-community-server x86_64 5.7.26-1.el7 mysql57-community 166 M
Installing for dependencies:
mysql-community-client x86_64 5.7.26-1.el7 mysql57-community 24 M
mysql-community-common x86_64 5.7.26-1.el7 mysql57-community 274 k
mysql-community-libs x86_64 5.7.26-1.el7 mysql57-community 2.2 M
Transaction Summary
=======================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 192 M
Installed size: 865 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): mysql-community-common-5.7.26-1.el7.x86_64.rpm | 274 kB 00:00:06
(2/4): mysql-community-libs-5.7.26-1.el7.x86_64.rpm | 2.2 MB 00:00:00
(3/4): mysql-community-client-5.7.26-1.el7.x86_64.rpm | 24 MB 00:00:15
(4/4): mysql-community-server-5.7.26-1.el7.x86_64.rpm | 166 MB 00:01:37
-------------------------------------------------------------------------------------------------------
Total 1.8 MB/s | 192 MB 00:01:45
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.10.1-7.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-7.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
Installing : mysql-community-common-5.7.26-1.el7.x86_64 1/4
Installing : mysql-community-libs-5.7.26-1.el7.x86_64 2/4
Installing : mysql-community-client-5.7.26-1.el7.x86_64 3/4
Installing : mysql-community-server-5.7.26-1.el7.x86_64 4/4
Verifying : mysql-community-server-5.7.26-1.el7.x86_64 1/4
Verifying : mysql-community-client-5.7.26-1.el7.x86_64 2/4
Verifying : mysql-community-libs-5.7.26-1.el7.x86_64 3/4
Verifying : mysql-community-common-5.7.26-1.el7.x86_64 4/4
Installed:
mysql-community-server.x86_64 0:5.7.26-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.26-1.el7 mysql-community-common.x86_64 0:5.7.26-1.el7
mysql-community-libs.x86_64 0:5.7.26-1.el7
Complete!
启动mysql
# 启动服务
[[email protected] opt]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
# 查看进程
[[email protected] opt]# ps aux | grep mysql | grep -v grep
mysql 13771 0.4 2.1 1119716 174720 ? Sl 16:23 0:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
# 设置开机启动
[[email protected] opt]# chkconfig mysqld on
Note: Forwarding request to 'systemctl enable mysqld.service'.
密码
安装过程中,会随[email protected]的数据库密码,需要使用此密码登陆,密码查看:
[[email protected] opt]# grep 'temporary password' /var/log/mysqld.log
2019-07-03T08:23:28.839644Z 1 [Note] A temporary password is generated for [email protected]: g0bah&VJ)j75