在CentOS7上安裝MySQL5.7可以用以下步驟:
1.下載MySQL5.7的repo:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
2.安裝repo:
sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm
3.安裝MySQL:
sudo yum install mysql-server
4.MySQL服務(wù)管理:
啟動(dòng)MySQL:sudo systemctl start mysqld.service
關(guān)閉MySQL:systemctl stop mysqld.service
查看MySQL狀態(tài):systemctl status mysqld.service
5.首次啟動(dòng)MySQL配置:
sudo grep 'password' /var/log/mysqld.log |tail -1
會(huì)出現(xiàn)這樣類似的一段話:A temporary password is generated for root@localhost: xxxxxxxxxx,
把里面的xxxxxxxxxx最后一段數(shù)字拷貝下來
使用以下命令修改root密碼:
sudo mysql_secure_installation
然后會(huì)提示輸入第一次臨時(shí)密碼和新密碼
6.登錄MySQL:
mysql -u root -p
然后輸入新密碼就可以登錄啦