数据库第一次作业

数据库第一次作业

一,数据库结构图

在这里插入图片描述

二,用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/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值