http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/mysql
http://dev.mysql.com/downloads/repo/yum/sql
下載到本地再上傳到服務器,或者使用wget 直接下載安全
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
將platform-and-version-specific-package-name
替換爲你下載的rpm名服務器
sudo rpm -Uvh platform-and-version-specific-package-name.rpm
例如網絡
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
yum install -y mysql-community-server
若是網絡環境不是很好,執行完命令就可能會等待一些是時間ide
service mysqld start systemctl start mysqld.service
service mysqld status systemctl status mysqld.service
Mysql5.7默認安裝以後root是有密碼的。ui
爲了增強安全性,MySQL5.7爲root用戶隨機生成了一個密碼,在error log中,關於error log的位置,若是安裝的是RPM包,則默認是/var/log/mysqld.log。
只有啓動過一次mysql才能夠查看臨時密碼this
grep 'temporary password' /var/log/mysqld.log
這裏的密碼是YdsGaxOq>2n!
spa
使用默認的密碼登錄code
mysql -uroot -p
用該密碼登陸到服務端後,必須立刻修改密碼,否則會報以下錯誤:
mysql> select @@log_error; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql>
修改密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';
若是密碼設置太簡單出現如下的提示
如何解決ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
呢? 這裏直接提供解決方案文末有詳細的說明
必須修改兩個全局參數:
首先,修改validate_password_policy參數的值
mysql> set global validate_password_policy=0;
再修改密碼的長度
mysql> set global validate_password_length=1;
再次執行修改密碼就能夠了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; FLUSH PRIVILEGES;