|NO.Z.00001|——————————|^^ 構建 ^^|——|Mysql.V5.7.35|
阿新 • • 發佈:2022-03-22
[Applications:Mysql.V5.7.35] [Applications.Databases] [|mysql5.7.35|centos7|安裝配置]
一、centos7安裝mysql5.7.27
### --- 下載 MySQL yum包
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
### --- 安裝MySQL源 rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
### --- 安裝MySQL服務端,需要等待一些時間
yum install -y mysql-community-server
### --- 啟動MySQL
systemctl start mysqld.service
### --- 檢查是否啟動成功
systemctl status mysqld.service
二、mysql授權
### --- 獲取臨時密碼,MySQL5.7為root使用者隨機生成了一個密碼
grep 'temporary password' /var/log/mysqld.log
### --- 通過臨時密碼登入MySQL,進行修改密碼操作 ### --- 使用臨時密碼登入後,不能進行其他的操作,否則會報錯,這時候我們進行修改密碼操作 mysql -uroot -p
### --- 因為MySQL的密碼規則需要很複雜,我們一般自己設定的不會設定成這樣,所以我們全域性修改一下
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
### --- 這時候我們就可以自己設定想要的密碼了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';
### --- 授權其他機器遠端登入 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION; FLUSH PRIVILEGES;
### --- 開啟開機自啟動:先退出mysql命令列,然後輸入以下命令
systemctl enable mysqld
systemctl daemon-reload
### --- 設定MySQL的字符集為UTF-8,令其支援中文
vim /etc/my.cnf
#改成如下,然後儲存
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysql]
default-character-set=utf8
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
default-storage-engine=INNODB
character_set_server=utf8
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
### --- 重啟一下MySQL,令配置生效
systemctl restart mysqld
### --- 防火牆開放3306埠
firewall-cmd --state
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
三、解除安裝mysql
### --- 解除安裝MySQL倉庫
### --- 一開始的時候我們安裝的yum,每次yum操作都會更新一次,耗費時間,我們把他解除安裝掉
rpm -qa | grep mysql
yum -y remove mysql57-community-release-el7-10.noarch
### --- 資料庫的操作
### --- 檢視mysql是否啟動:service mysqld status
~~~ 啟動mysql:service mysqld start
~~~ 停止mysql:service mysqld stop
~~~ 重啟mysql:service mysqld restart
### --- 檢視臨時密碼:grep password /var/log/mysqld.log
附錄一:
### --- 輔助資料:
https://www.cnblogs.com/jinghuyue/p/11565564.html
===============================END===============================
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor
來自為知筆記(Wiz)