CentOS 7使用yum配置MySQL源並安裝MySQL

1.因爲CentOS 的yum源中沒有mysql,須要到mysql的官網下載yum repo配置文件。

wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.安裝yum repo文件

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

執行完成後會在/etc/yum.repos.d/目錄下生成兩個repo文件mysql-community.repo mysql-community-source.repomysql

3.而後更新yum緩存

yum clean all
yum makecache

4.安裝mysql

yum install mysql-community-client.x86_64 mysql-community-common.x86_64 mysql-community-devel.x86_64 mysql-community-libs.x86_64 mysql-community-server.x86_64

或者sql

rpm install mysql-server

5.啓動mysql

service mysqld start

6.查看初始密碼

grep 'temporary password' /var/log/mysqld.log

獲得以下內容:緩存

2016-10-28T10:36:32.369073Z 1 [Note] A temporary password is generated for root@localhost: 5Oazqgpiat!p

7.使用初始密碼登陸

mysql -u root -p //回車,而後輸入上一步查到的初始密碼

8.更改初始密碼

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
//如今的mysql對密碼強度要求較高,須要包含大小寫字母、數字和特殊字符

至此,mysql-server安裝完成code

相關文章
相關標籤/搜索