ENV:
[root@centos7 ~]# uname -r
3.10.0-514.el7.x86_64
[root@centos7 ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
现在的好多服务器网站都是采用的LNMP,就是 Linux+Nginx+Mysql(Mongodb)+Php这四个部分,最好的软件安装方式还是源码包安装,服务会更稳定,但是现在讲yum安装,而源码包安装以后再讲述,这章讲yum安装mysql
1.安装mysql的yum安装源
进入mysql官网 下载页 https://www.mysql.com/downloads/ 选最下方的MySQL Community Edition(GPL),这个是社区免费版。
之后在https://dev.mysql.com/downloads/页面选择第一个MySQL Community Server到版本选择页https://dev.mysql.com/downloads/mysql/ 如果想用最新的版本,可以直接下载8.0版本,但是我们一般会选低一些的稳定版,在右侧,我们选择5.7版的下载rpm格式的server版本。
直接运行命令
[root@centos7 ~]# yum install -y http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Loaded plugins: fastestmirror, langpacks
mysql57-community-release-el7-11.noarch.rpm | 25 kB 00:00
Examining /var/tmp/yum-root-m0H4Wj/mysql57-community-release-el7-11.noarch.rpm: mysql57-community-release-el7-11.noarch
Marking /var/tmp/yum-root-m0H4Wj/mysql57-community-release-el7-11.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-11 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version
Repository Size
================================================================================
Installing:
mysql57-community-release
noarch el7-11 /mysql57-community-release-el7-11.noarch 31 k
Transaction Summary
================================================================================
Install 1 Package
Total size: 31 k
Installed size: 31 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql57-community-release-el7-11.noarch 1/1
Verifying : mysql57-community-release-el7-11.noarch 1/1
Installed:
mysql57-community-release.noarch 0:el7-11
Complete!
2.yum安装server
[root@centos7 ~]# yum install -y mysql-community-server
因重新下载安装太慢,过程省略,等待安装完成即可
3.启动服务和加入开机启动
[root@centos7 ~]# systemctl start mysqld
[root@centos7 ~]# systemctl enable mysqld
mysql的安装就结束了。