1.安裝 wget 命令
yum -y install wget
2.下載mysql源碼包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
3.修改安裝mysql包版本
vi /etc/yum.repos.d/mysql-community.repo
改變默認(rèn)安裝的mysql版本。比如要安裝5.6版本实柠,將5.7源的enabled=1改成enabled=0悄但。然后再將5.6源的enabled=0改成enabled=1即可
4.安裝mysql
yum install mysql-community-server
5.啟動(dòng)mysql
systemctl start mysqld
6.查看mysql啟動(dòng)狀態(tài)
systemctl status mysqld
7.查看mysql版本
mysqld --version
8.設(shè)置開(kāi)機(jī)啟動(dòng)
systemctl enable mysqld
systemctl daemon-reload
9.找到安裝時(shí)設(shè)置的默認(rèn)密碼
grep 'temporary password' /var/log/mysqld.log
密碼日志 : 2018-12-03T14:54:06.651986Z 1 [Note] A temporary password is generated for root@localhost: o9kWqD?i6<SU
密碼:o9kWqD?i6<SU
10.輸入密碼進(jìn)入mysql命令行
mysql -uroot -p
? 回車輸入 步驟 9 中的密碼,進(jìn)入mysql命令行
11.進(jìn)入mysql命令行后修改密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY '1234!1234Labcd';
修改后 root 用戶密碼為 '1234!1234Labcd'
12.刷新權(quán)限
FLUSH PRIVILEGES;
13.修改/etc/my.cnf配置文件写隶,在[mysqld]下添加編碼配置陨献,如下所示:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
14.重啟mysql
shell> systemctl restart mysqld
15.進(jìn)入mysql命令行查看編碼 (使用 mysql -uroot -p 進(jìn)入mysql命令行)
show variables like '%character%';
16.添加遠(yuǎn)程登陸用戶
GRANT ALL PRIVILEGES ON *.* TO 'setsuna'@'%' IDENTIFIED BY 'Setsuna_Pisces313!' WITH GRANT OPTION;
'setsuna'@'%' 中'@'%寫(xiě)死的暫時(shí)不用管它爪膊, 遠(yuǎn)程用戶名為: setsuna 密碼為: Setsuna_Pisces313!
17.默認(rèn)配置文件路徑(請(qǐng)根據(jù)需求自行修改)
默認(rèn)配置文件路徑:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服務(wù)啟動(dòng)腳本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
查看安裝目錄: show variables like "%char%";
18.設(shè)置防火墻
firewall-cmd --zone=public --add-port=3306/tcp --permanent
重啟防火墻
firewall-cmd --reload
查看防火墻狀態(tài)
firewall-cmd --state