接下來我們?cè)?Centos7 系統(tǒng)下使用 yum 命令安裝 MySQL,需要注意的是 CentOS 7 版本中 MySQL數(shù)據(jù)庫已從默認(rèn)的程序列表中移除,所以在安裝前我們需要先去官網(wǎng)下載 Yum 資源包: [root@iZr3vdn5bmnf2lZ ~]# wget -i -c http://dev./get/mysql57-community-release-el7-10.noarch.rpm 使用yum安裝mysql: [root@iZr3vdn5bmnf2lZ ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm [root@iZr3vdn5bmnf2lZ ~]# yum -y install mysql-community-server 啟動(dòng)mysql,并查看mysql運(yùn)行狀態(tài): [root@iZr3vdn5bmnf2lZ ~]# systemctl start mysqld [root@iZr3vdn5bmnf2lZ ~]# systemctl status mysqld 安裝成功,找出mysql的初始密碼: [root@iZr3vdn5bmnf2lZ ~]# grep "password" /var/log/mysqld.log 使用此密碼登錄數(shù)據(jù)庫: [root@iZr3vdn5bmnf2lZ ~]# mysql -uroot -p 根據(jù)提示輸入剛才查到的密碼。 登錄成功后修改密碼: mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密碼'; 但此時(shí)還有一個(gè)問題,就是因?yàn)榘惭b了Yum Repository,以后每次yum操作都會(huì)自動(dòng)更新,需要把這個(gè)卸載掉: 如果需要開放外網(wǎng): mysql> grant all on *.* to root@'%' identified by '剛設(shè)置的新密碼'; 配置完成,但此時(shí)還有一個(gè)問題,就是因?yàn)榘惭b了Yum Repository,以后每次yum操作都會(huì)自動(dòng)更新,需要把這個(gè)卸載掉: [root@iZr3vdn5bmnf2lZ ~]# yum -y remove mysql57-community-release-el7-10.noarch
|
|