当前位置:   article > 正文

数据库安装四种方法

数据库安装

 

安装数据库
一、在网上下载安装包
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
启动服务
systemctl start mysqld
查看服务状态
systemctl status mysqld.service
查看初始密码,登录MySQL修改密码
grep passwor /var/log/mysqld.log
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyGirlIsBy520!';
安装完成,重新登录查看
mysql> show databases;

二、离线安装
打开链接https://dev.mysql.com/downloads/,选择对应的版本进行下载即可。
将下载好的文件传入Redhat中的某个路径中
dnf install lrzsz -y
rz

解压
tar -xvf mysql-8.0.27-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

启动服务
systemctl start mysqld
查看服务状态
systemctl status mysqld.service
查看初始密码,登录MySQL修改密码
grep passwor /var/log/mysqld.log
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyGirlIsBy520!';
安装完成,重新登录查看
mysql> show databases;

三、容器安装
容器安装——>了解容器——>虚拟化

工作站级别的虚拟化
企业级虚拟化

清理系统
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine

安装必要的包
dnf install -y yum-utils device-mapper-persistent-data lvm2

添加仓库
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

查看
ll /etc/yum.repos.d/

安装最新的docker
dnf install docker-ce docker-ce-cli

wget http://mirrors.163.com/centos/8/BaseOS/x86_64/os/Packages/yum-4.2.23-4.el8.noarch.rpm /
wget http://mirrors.163.com/centos/8/BaseOS/x86_64/os/Packages/yum-utils-4.0.17-5.el8.noarch.rpm /
wget http://mirrors.163.com/centos/8/BaseOS/x86_64/os/Packages/python3-urllib3-1.24.2-4.el8.noarch.rpm
启动
systemctl start docker
查看服务状态
systemctl status docker
查看版本
docker version
运行mysql
docker run mysql(提示错误)
docker run --name mysqltest -e MYSQL_ROOT_PASSWORD=123456 -d mysql
指定名称,密码运行

进入容器
docker exec -it mysqltest /bin/bash
登录数据库
mysql -uroot -p
推出容器
exit
停止容器内服务的运行
docker stop 数据库名称
停止容器
systemctl stop docker

四、源码安装
下载包
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
创建解压目录,并移动包到该目录下解压
mkdir /mysql \
move mysql-boost-8.0.30.tar.gz /mysql \
cd /mysql \
tar zxvf mysql-boost-8.0.30.tar.gz
cd mysql-8.0.30

mkdir bld
cd bld

dnf install cmake
cmake ..
解决依赖问题
cmake ..
指定目录
cmake ..  -DWITH_BOOST=../boost/boost_1_77_0/
解决依赖问题
dnf install -y openssl-devel
dnf install -y ncurses-devel
yum install libtirpc-devel -y
rpm -i rpcgen-1.3.1-4.el8.x86_64.rpm(仓库没有,网上下载)

cd /mysql/mysql-8.0.30/bld
make //平均四小时
make install

make;make install //两个命令一起做,前面做完了做后面


# 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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/228025
推荐阅读
相关标签
  

闽ICP备14008679号