最新!linux mysql安裝

sayWhat_sayHello發表於2018-07-31

為了寫這篇部落格,我安裝了3個虛擬機器…
這裡是centos7,另外是首次安裝mysql,如果之前有安裝先解除安裝:
yum -y remove mysql-libs.x86_64
這裡我實驗3次的是mysql8.0版本,5.7版本應該類似,這裡給出5.7的網址

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
選擇mysql版本:
https://dev.mysql.com/downloads/repo/yum/

這裡選擇是mysql8.0
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

rpm -ivh mysql80-community-release-el7-1.noarch.rpm
yum install -y mysql-server

mysqld --initialize(稍等)
cd /var/lib/mysql && ll
chmod -R 777 /var/lib/mysql
ll(檢驗ibdata1的許可權是否為777)

systemctl start mysqld
systemctl status mysqld

mysqladmin --version
sudo grep 'temporary password' /var/log/mysqld.log複製密碼
mysql -u root -p輸入密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; 修改密碼為123456


如果報錯,注意檢視日誌檔案!
mysql日誌檔案:/var/log/mysqld.log
mysql安裝路徑:/var/lib/mysql
mysql啟動位置:/var/bin/mysql
參考網站:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

相關文章