添加 install-myaql.sh
This commit is contained in:
commit
1741af7189
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# 准备MySQL的yum仓库
|
||||
yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-11.noarch.rpm
|
||||
# 修改安装版本,启用5.7版本
|
||||
yum -y install yum-utils
|
||||
yum-config-manager --disable mysql80-community
|
||||
yum-config-manager --enable mysql57-community
|
||||
|
||||
# 安装MySQL服务器和客户端
|
||||
yum -y install mysql mysql-server mysql-community-client mysql-community-server
|
||||
|
||||
# 初始化MySQL服务
|
||||
systemctl start mysqld
|
||||
systemctl enable mysqld
|
||||
|
||||
# 获取MySQL生成的临时密码
|
||||
MYSQL_ROOT_PASSWORD=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}')
|
||||
|
||||
# 提示用户输入新的密码
|
||||
echo "请输入新的MySQL root用户密码:"
|
||||
read -s NEW_MYSQL_ROOT_PASSWORD
|
||||
echo
|
||||
|
||||
# 使用mysql客户端直接登录并设置密码
|
||||
mysqladmin -uroot -p$MYSQL_ROOT_PASSWORD password "$NEW_MYSQL_ROOT_PASSWORD"
|
Loading…
Reference in New Issue