歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

centos使用yum安裝mysql

1.增加yum數據源   (1.1)從http://dev.mysql.com/downloads/repo/yum/ 獲取合適的數據源   (1.2)安裝數據源包   shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm eg:安裝 Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package   shell> wget http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm shell> sudo rpm-Uvh mysql57-community-release-el7-7.noarch.rpm 2.選擇合適的安裝版本   (2.1)查看mysql數據源中存在的包    shell> sudo yum repolist all | grep mysql (2.2)編輯 /etc/yum.repos.d/mysql-community.repo,啟用相應的mysql版本     # 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/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql   [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql     ps: "enabled=1" 啟用,"enabled=0" 禁用,上述配置則是安裝"mysql 5.7",禁用"mysql 5.6"   (2.3)查看mysql啟用列表   shell > sudo yum repolist enabled | grep mysql mysql-connectors-community/x86_64      MySQL Connectors Community            17 mysql-tools-community/x86_64           MySQL Tools Community                 27 mysql57-community/x86_64               MySQL 5.7 Community Server            20  3.安裝mysql   shell> sudo yum install mysql-community-server    注意:在使用yum 安裝 mysql 5.7過程中,會隨機生成一個臨時的root密碼保存到錯誤日志("/var/log/mysqld.log"),可以使用如下命令進行查看:   shell > sudo grep 'temporary password' /var/log/mysqld.log  因此安裝mysql 5.7後,需要盡快修改密碼。   4.啟動mysql服務器   shell> yum --disablerepo=\* --enablerepo='mysql*-community*' list available (4.1)啟動命令   shell> sudo service mysqld start (4.2)查看mysql狀態   shell> sudo service mysqld status 5.mysql_secure_installation   使用mysql_secure_installation設置root密碼,刪除匿名用戶等重要操作   shell> mysql_secure_installation     6.安裝mysql額外工具   (6.1)查看可用包名   shell> mysql_secure_installation (6.2)安裝包   shell> sudo yum install 包名 如:安裝 mysql-workbench-community   shell> sudo yum install mysql-workbench-community   7.升級mysql   (7.1)編輯 /etc/yum.repos.d/mysql-community.repo   (7.2)執行update   shell> sudo yum update mysql-server  或者使用下述命令更新所有包   shell> sudo yum update 8. centos7默認使用mariadb數據庫代替mysql,先將mariadb相關包卸載   (8.1)查詢 maridb 包命令   shell> sudo rpm -qa | grep -i mariadb (8.2)刪除    shell> sudo rpm -e 相關包名
Copyright © Linux教程網 All Rights Reserved