1.配置YUM源mysql
下載mysql源安裝包:sql
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch安全
安裝mysql源,安裝過程當中遇到Is this ok [y/d/N]的直接輸入y便可:socket
yum localinstall mysql57-community-release-el7-11.noarch.rpmthis
檢查mysql源是否安裝成功:編碼
yum repolist enabled | grep "mysql.*-community.*"插件
2.安裝MySQL,安裝過程當中遇到Is this ok [y/d/N]的直接輸入y便可日誌
yum install mysql-community-serverserver
Note:可經過修改/etc/yum.repos.d/mysql-community.repo源中的enabled【1表示選擇】的值來選擇安裝的MySQL版本get
3.啓動MySQL服務
systemctl start mysqld
查看MySQL的啓動狀態
systemctl status mysqld
4.開機啓動
systemctl enable mysqld
systemctl daemon-reload
5.修改root本地登陸密碼
獲取MySQL默認密碼:
grep 'temporary password' /var/log/mysqld.log
登錄MySQL:
mysql -uroot -p
修改默認密碼:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password';
或者
set password for 'root'@'localhost'=password('Password');
Note:MySQL5.7默認安裝了密碼安全檢查插件(validate_password),默認密碼檢查策略要求密碼必須包含:大小寫字母、數字和特殊符號,而且長度不能少於8位。?
6.添加遠程登陸用戶
默認只容許root賬戶在本地登陸,若是要在其它機器上鍊接mysql,必須修改root容許遠程鏈接,或者添加一個容許遠程鏈接的賬戶:
GRANT ALL PRIVILEGES ON *.* TO 'account'@'%' IDENTIFIED BY 'pwd' WITH GRANT OPTION;
7.配置默認編碼爲utf8
show variables like '%character%';
修改/etc/my.cnf配置文件:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
從新啓動mysql服務便可完成修改
8.默認配置文件路徑
配置文件:/etc/my.cnf
日誌文件:/var/log//var/log/mysqld.log
服務啓動腳本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid