MySQL 5.7安装脚本(CentOS 7.7)

1、编辑MySQL 安装脚本

sudo vim az-mysql.sh
#!/bin/bash

echo "INFO:============== 开始安装 MySQL =============="
sudo yum remove '*mysql-community*'
sudo rpm -qa | grep -i mysql | xargs rpm -e --nodeps
sudo find / -name '*mysql-community*'|xargs rm -rf

sudo find / -name mysql -type d -exec rm -rf {} \;
sudo rm –rf /usr/my.cnf
sudo rm -rf /root/.mysql_sercret 
sudo rm -rf /etc/my.cnf
sudo rm -rf /var/log/mysqld.log

sudo rpm -ivh http://repo.mysql.com/mysql57-community-release-el7.rpm

sudo yum list all | grep mysql-community
sudo yum -y install mysql-community-client
sudo yum -y install mysql-community-common
sudo yum -y install mysql-community-devel
sudo yum -y install mysql-community-libs
sudo yum -y install mysql-community-libs-compat
sudo yum -y install mysql-community-server
sudo yum -y install mysql-community-test

sudo mysqld --initialize --user=mysql --datadir=/var/lib/mysql --basedir=/usr/local/mysql

echo "INFO:============ MySQL安装完成,请手动配置 MySQL =============="

你可能感兴趣的:(笔记)