数据库第一次作业
一,数据库结构图
二,用shell 脚本 安装MYSQL数据库
1,yum 在线安装
#!/bin/bash
#########################
#File name:yum_install_mysql.sh
#Version:v1.0
#Email:admin@test.com
#Created time:2022-09-12 15:02:43
#Description:
#########################
rpm -i https://repo.mysql.com//mysql80-community-release-el8-4.noarch.rpm
dnf install mysql-server -y
rpm -qa | grep mysql
2,本地安装
#!/bin/bash
#########################
#File name:local_install_MYSQL.sh
#Version:v1.0
#Email:admin@test.com
#Created time:2022-09-12 15:08:45
#Description:
#########################
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar
tar xvf mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar
dnf localinstall mysql-community-server-8.0.30-1.el8.x86_64.rpm \
mysql-community-client-8.0.30-1.el8.x86_64.rpm \
mysql-community-common-8.0.30-1.el8.x86_64.rpm \
mysql-community-icu-data-files-8.0.30-1.el8.x86_64.rpm \
mysql-community-client-plugins-8.0.30-1.el8.x86_64.rpm \
mysql-community-libs-8.0.30-1.el8.x86_64.rpm
3,容器安装
#!/bin/bash
#########################
#File name:docker_install_mysql.sh
#Version:v1.0
#Email:admin@test.com
#Created time:2022-09-12 15:13:38
#Description:
#########################
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
ll /etc/yum.repos.d/
dnf remove runc -y
dnf install docker-ce docker-ce-cli -y
systemctl start docker
systemctl status docker
docker run mysql
docker run --name mysqltest -e MYSQL_ROOT_PASSWORD=123456 -d mysql
4,源码安装
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.30.tar.gz
# Preconfiguration setup
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
# Beginning of source-build specific instructions
tar zxvf mysql-VERSION.tar.gz
cd mysql-VERSION
mkdir bld
cd bld
yum install cmake gcc-toolset-11-gcc gcc-toolset-11-gcc-c++ gcc-toolset-11-binutils openssl-devel ncurses-devel libtirpc-devel -y
rpm -i rpcgen-1.3.1-4.el8.x86_64.rpm
cmake .. -DWITH_BOOST=../boost/boost_1_77_0/
make ########该过程平均4个小时 ########
make install
make;make install
等编译安装完成
# End of source-build specific instructions
# Postinstallation setup
cd /usr/local/mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files
bin/mysqld --initialize --user=mysql
bin/mysql_ssl_rsa_setup
bin/mysqld_safe --user=mysql &
# Next command is optional
cp support-files/mysql.server /etc/init.d/mysql.server
三、卸载数据库
dnf remove mysql-server
rpm -e mysql80-community-release
rpm -qa | grep mysql
rm -rf /var/lib/mysql/
rm -rf /var/log/mysql/