CentOS 7 安裝 mysql 有不少方法,網上看了一些列子,不多有一步成功的。其實官網已經給出了很簡單的方式mysql
官網說明sql
官網下載地址ide
由於是 CentOS7 我選擇的是Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Packageui
好比我複製下來是 :https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpmcode
mkdir /home/mysql cd /home/mysql wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
如下命名在 /home/mysql 目錄下執行,或者加上目錄路徑執行也可server
rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
若是沒有權限,用 sudo 執行get
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-connectors-community/x86_64 MySQL Connectors Community enabled: 45 mysql-connectors-community-source MySQL Connectors Community - disabled mysql-tools-community/x86_64 MySQL Tools Community enabled: 59 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: 247 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
enabled,表示默認安裝版本, 默認爲5.7博客
關閉5.7版本安裝 yum-config-manager --disable mysql57-community
打開55版本安裝 yum-config-manager --enable mysql55-community
yum-config-manager
沒法執行,這個是由於系統默認沒有安裝這個命令,這個命令在yum-utils 包裏,能夠經過命令yum -y install yum-utils
安裝就能夠了it
yum repolist all | grep mysql
或者gui
yum repolist enabled | grep mysql
查看當前 enabled 的 mysql 版本,若是是你設置的版本。就能夠安裝了。
yum install mysql-community-server
默認安裝後的 mysql 是沒有密碼,請儘快設置。
set password for 'root'@'localhost' = PASSWORD('newpassword');
廣告欄: 歡迎關注個人 我的博客