centos7 mysql 一鍵安裝指令碼

BB**●﹏●K發表於2020-11-26
#!/bin/shell

# 快速安裝MySQL
# CentOS7 中已成功驗證
# 使用yum+rpm方式安裝
# quick-install of mysql5.7

# 配置阿里雲yum映象源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all

yum makecache

# 下載mysql rpm
wget http://repo.mysql.com/mysql57-community-release-el7.rpm

# 安裝rpm
rpm -ivh http://repo.mysql.com/mysql57-community-release-el7.rpm
# yum 安裝mysql服務
yum install -y mysql-community-server

# 啟動mysql服務
systemctl start mysqld.service

# 檢視mysql服務狀態
systemctl status mysqld.service

# 檢視安裝的mysql密碼
grep 'temporary password' /var/log/mysqld.log

TEMP_PWD=$(grep 'temporary password' /var/log/mysqld.log)
PWD=${TEMP_PWD##* }
echo "${PWD}"

# 登入
mysql -uroot -p${PWD}

# 更改密碼策略為LOW
# set global validate_password_policy=0;
# 更改密碼長度
# set global validate_password_length=0;
# 如此即可隨意設定密碼:
# set password for 'root'@'localhost'=password('123456');

# 使用新密碼登陸
# exit
# mysql -uroot -pbpgbpg++


# 匯入你自己的資料庫指令碼
# use mysql;
# source /your_own_path/you_own_sql.sql

參考連結:
(需要安裝8.0看這個)
mysql8.0的一鍵安裝
mysql5.7密碼策略及修改技巧

相關文章