一、配置YUM源html
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpmmysql
shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
檢查MySQL源是否安裝成功
shell> yum repolist enabled | grep 「mysql.-community.」 sql
二、安裝MySQL
shell> yum install mysql-community-server
三、啓動MySQL服務
shell> systemctl start mysqld
查看MySQL的啓動狀態
shell> systemctl status mysqldshell
四、開機啓動
shell> systemctl enable mysqld
shell> systemctl daemon-reload數據庫
五、修改root本地登陸密碼
grep ‘temporary password’ /var/log/mysqld.log
mysql -uroot –p+生產注意:mysql5.7默認安裝了密碼安全檢查插件(validate_password),默認密碼檢查策略要求密碼必須包含:大小寫字母、數字和特殊符號,而且長度不能少於8位。不然會提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements錯誤,以下圖所示:centos
六、添加遠程登陸用戶
默認只容許root賬戶在本地登陸,若是要在其它機器上鍊接mysql,必須修改root容許遠程鏈接,或者添加一個容許遠程鏈接的賬戶,
mysql> GRANT ALL PRIVILEGES ON . TO ‘*’@’ localhost’ IDENTIFIED BY ’ MyNewPass4!’ WITH GRANT OPTION;安全
GRANT ALL PRIVILEGES ON . TO ‘*’@’ Spark’ IDENTIFIED BY ’ MyNewPass4!’ WITH GRANT OPTION;socket
七、配置默認編碼爲utf8ide
修改/etc/my.cnf配置文件,在[mysqld]下添加編碼配置,以下所示:
[mysqld]
character_set_server=utf8
init_connect=’SET NAMES utf8’post
常見問題:
1.ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this ..
解決:首先修改用戶的密碼。(下面兩個命令一個意思,任選其一便可)
alter user 'root'@'localhost' identified by 'youpassword';
set password=password("youpassword");
而後在刷新權限。
flush privileges;
2.MySQ修改密碼報錯ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解決:
默認配置文件路徑:
配置文件:/etc/my.cnf
日誌文件:/var/log//var/log/mysqld.log
服務啓動腳本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
轉發自:https://www.centoschina.cn/server/sql/mysql/8661.html