CentOS 7 yum安裝mysql
一:去官網查看最新安裝包
https://dev.mysql.com/downloads/repo/yum/
二:下載MySQL源安裝包
mysql80-community-release-el7-1.noarch.rpm
安裝MySql源
yum -y install mysql80-community-release-el7-1.noarch.rpm
yum repolist all | grep mysql
三:安裝MySQL服務器
yum install mysql-community-server
中間會彈出是與否的選擇,選擇y即可,然後耐心等待吧。。。。。。。
四:啟動MySQL服務
systemctl start mysqld.service
運行一下命令查看一下運行狀態
systemctl status mysqld.service
五:初始化數據庫密碼
查看一下初始密碼
grep "password" /var/log/mysqld.log
登錄
mysql -uroot -p
修改密碼
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘****************‘;
mysql默認安裝了密碼安全檢查插件(validate_password),默認密碼檢查策略要求密碼必須包含:大小寫字母、數字和特殊符號,並且長度不能少於8位。否則會提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements錯誤
六:數據庫授權
數據庫沒有授權,只支持localhost本地訪問
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
//遠程連接數據庫的時候需要輸入用戶名和密碼
用戶名:root
密碼:123456
mysql>FLUSH PRIVILEGES;
也可以通過修改表來實現遠程:
mysql -u root -p
mysql> use mysql;
mysql> update user set host = ‘%‘ where user = ‘root‘;
七:設置自動啟動
systemctl enable mysqld
systemctl daemon-reload
CentOS 7 yum安裝mysql