1.在线yun库
配置本地仓库
bash
[root@192 ~]# cd /etc/yum.repos.d/
[root@192 yum.repos.d]# vim s.repo
[baseos]
name=baseos
baseurl=/mnt/BaseOS
enable=1
gpgcheck=0
[app]
name=appstream
baseurl=/mnt/AppStream
enable=1
gpgcheck=0
~
~
挂载
[root@192 ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
下载mysql
bash
#1
[root@192 ~]# wget https://repo.mysql.com//mysql84-community-release-el9-1.noarch.rpm
#2
[root@192 ~]# rpm -i https://repo.mysql.com//mysql84-community-release-el9-1.noarch.rpm
[root@192 ~]# dnf repolist
仓库 id 仓库名称
app appstream
baseos baseos
mysql-8.4-lts-community MySQL 8.4 LTS Community Server
mysql-connectors-community MySQL Connectors Community
mysql-tools-8.4-lts-community MySQL Tools 8.4 LTS Community
点击MySQL Community (GPL) Downloads
通过仓库安装mysql数据库
bash
[root@192 ~]# dnf install mysql-server
#启动mysql服务
[root@192 ~]# systemctl start mysqld
#检查mysql服务状态
[root@192 ~]# systemctl status mysqld
#使用-先查看临时密码
[root@192 ~]# grep password /var/log/mysqld.log
2025-01-06T10:58:32.835071Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >I%5&o;m:d)b
[root@192 ~]# mysql -uroot -p
Enter password:
mysql> alter user 'root'@'localhost' identified by '大写小写数字特殊字符';
mysql> show databases
删除下载的mysql数据库
bash
[root@192 ~]# dnf remove mysql-server -y
[root@192 ~]# rm -rf /var/lib/mysql
[root@192 ~]# rm -rf /var/log/mysqld.log
[root@192 ~]# userdel -r mysql
userdel:mysql 信件池 (/var/spool/mail/mysql) 未找到
userdel:未找到 mysql 的主目录"/var/lib/mysql"
[root@192 ~]# rpm -qa | grep mysql
mysql84-community-release-el9-1.noarch
[root@192 ~]# dnf remove mysql84-community-release
[root@192 ~]# find / -name mysql
[root@192 ~]# rm -rf /usr/lib64/mysql
#删除所有mysql相关
[root@192 ~]# ll
[root@192 ~]# rm -rf mysql*
2.二进制本地
随后下载
bash
#用wget下载地址链接
[root@192 ~]#wget hhttps://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.3-1.el9.x86_64.rpm-bundle.tar
#解压.tar包
tar xf mysql-8.4.3-1.el9.x86_64.rpm-bundle.tar.1
#查看
[root@192 ~]# ll mysql-*
进行安装
bash
[root@192 ~]# dnf localinstall mysql-community-server-8.4.3-1.el9.x86_64.rpm
3.容器平台
(1)删除之前的容器安装
bash
#查看是否有docker
[root@192 ~]# rpm -qa | grep docker
#删除
[root@192 ~]# dnf remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine \
> podman \
> runc
(2)配置仓库软件
bash
#dnf插件
[root@192 ~]# dnf -y install dnf-plugins-core
#添加docker仓库
[root@192 ~]# dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
添加仓库自:https://download.docker.com/linux/rhel/docker-ce.repo
查看仓库
bash
[root@192 ~]# dnf repolist
(3)安装docker相关软件
bash
[root@192 ~]# dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
#若上述操作无法完成使用docker压缩包解压后安装
[root@192 ~]# tar xf Docker_Install.xz
[root@192 ~]# dnf localinstall containerd.io-1.7.24-3.1.el9.x86_64.rpm docker-buildx-plugin-0.19.3-1.el9.x86_64.rpm docker-ce-27.4.1-1.el9.x86_64.rpm docker-ce-cli-27.4.1-1.el9.x86_64.rpm docker-ce-rootless-extras-27.4.1-1.el9.x86_64.rpm docker-compose-plugin-2.32.1-1.el9.x86_64.rpm
(4)启动docker服务
bash
[root@192 ~]# systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
(5)docker镜像仓库
bash
#需要科学上网
[root@192 ~]# docker search mysql
[root@192 ~]# docker pull mysql:8.4.3
#若无法正常使用,外部导入镜像
[root@192 ~]# docker load -i MySQL910.tar
#导出镜像的指令
#docker save -o MySQL843.tar mysql:8.4.3
#查看
[root@192 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 56a8c14e1404 2 months ago 603M
启动容器
bash
#-d之后repository:tag
[root@192 ~]# docker run --name mysqltest -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest
eb175fa14138b474d9efc2c12ae5fec3c606c02bda2c5d22812bedc43cba22db
查看并测试
bash
[root@192 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eb175fa14138 mysql:latest "docker-entrypoint.s..." 5 minutes ago Up 5 minutes 3306/tcp, 33060/tcp mysqltest
[root@192 ~]# docker exec -it mysqltest /bin/bash
bash-5.1# mysql -uroot -p
4.源码部署
5.Windows平台
下载后next点击即可
配置环境变量