首先:具體的安裝步驟在mysql官方文檔上都有詳細的描述。html
文檔雖然是英文,不過很容易理解,我就不一一翻譯了。mysql
官方文檔地址:https://dev.mysql.com/doc/refman/5.6/en/linux-installation-yum-repo.htmllinux
目前mysql最新版本爲:5.7.xsql
但由於5.7版本比以前版本改動比較大,因此項目中通常仍是在用5.6版本。vim
一、Adding the MySQL Yum Repositorycentos
Go to the Download MySQL Yum Repository page (http://dev.mysql.com/downloads/repo/yum/) in the MySQL Developer Zone.ide
由於centos版本是7.x,至於爲何是mysql57-community-release-el7-11.noarch.rpm,文檔中有以下解釋:url
The repository packages available below will provide MySQL Server 5.7 by default. Other versions can be obtained by editing the repo setup file installed by the package. spa
yum localinstall mysql57-community-release-el7-11.noarch.rpm
ps:如何卸載 yum localinstall翻譯
# 先查看已經安裝的rpm包 rpm -qa|grep mysql mysql-libs-5.1.73-8.el6_8.x86_64 mysql80-community-release-el7-1.noarch # 卸載上一步獲得的兩個rpm包 yum remove mysql-libs-5.1.73-8.el6_8.x86_64 yum remove mysql80-community-release-el7-1.noarch
You can check that the MySQL Yum repository has been successfully added by the following command:
yum repolist enabled | grep "mysql.*-community.*"
Selecting a Release Series
vim /etc/yum.repos.d/mysql-community.repo
# Specify enabled=0 to disable a subrepository,or enabled=1 to enable a subrepository. # Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
You should only enable subrepository for one release series at any time. When subrepositories for more than one release series are enabled, the latest series will be used by Yum.
Verify that the correct subrepositories have been enabled and disabled by running the following command and checking its output:
yum repolist enabled | grep mysql
二、Install MySQL by the following command:
yum install mysql-community-server
若是你只想安裝mysql client或者mysqldump等,可執行以下命令
yum install mysql-community-client
Start the MySQL server with the following command:
systemctl start mysqld.service
Check the status of the MySQL server with the following command:
systemctl status mysqld.service
三、安裝後的mySql配置文件位置
/etc/my.cnf
有問題歡迎留言交流。
技術交流羣:282575808
--------------------------------------
聲明: 原創文章,未經容許,禁止轉載!
--------------------------------------