【Mysql】mysql三种安装方式(二进制、yum、docker)

news2024/9/22 13:33:25

一、环境信息

        centos7.6_x86、glib2.17

mysql官网下载地址:MySQL :: Download MySQL Community Server

二、 二进制安装

#下载解压安装包
[root@hadoop03 ~]# wget -c https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.39-linux-glibc2.17-x86_64.tar.xz
[root@hadoop03 ~]# xz -d mysql-8.0.39-linux-glibc2.17-x86_64.tar.xz
[root@hadoop03 ~]# tar -xvf mysql-8.0.39-linux-glibc2.17-x86_64.tar
[root@hadoop03 ~]# mv mysql-8.0.39-linux-glibc2.17-x86_64 mysql
[root@hadoop03 ~]# mv mysql /usr/local/
#创建数据存放目录以及日志目录、mysql.sock文件存放目录
[root@hadoop03 mysql]# mkdir /data/mysql/{data,logs,run} -p
#以普通用户启动mysql,所以需要更改目录权限
[root@hadoop03 mysql]# chown admin:admin -R /usr/local/mysql/
[root@hadoop03 mysql]# chown admin:admin -R /data/
#编写配置文件my.cnf
[root@hadoop03 mysql]# su admin
[admin@hadoop03 mysql]$ vi my.cnf
[mysqld_safe]
pid-file=/data/mysql/logs/mysqld.pid
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/data/mysql/run/mysql.sock
log_error=/data/mysql/logs/alert.log
pid_file=/data/mysql/logs/mysqld.pid
#初始化mysql
[admin@hadoop03 mysql]$ ./bin/mysqld --defaults-file=/usr/local/mysql/my.cnf --initialize-insecure
#启动mysql
[admin@hadoop03 mysql]$ ./bin/mysqld_safe --defaults-file=my.cnf &
#进入mysql,也可以./bin/mysql -S /data/mysql/run/mysql.sock命令进入
[admin@hadoop03 mysql]$ ./bin/mysql -uroot -h127.0.0.1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.39 MySQL Community Server - GPL

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

三、 yum方式安装

官网下载地址:MySQL :: Download MySQL Yum Repository

[root@hadoop03 ~]# rpm -ivh mysql84-community-release-el7-1.noarch.rpm
#安装依赖
[root@hadoop03 yum.repos.d]# yum install perl net-tools -y
[root@hadoop03 ~]#  yum install  mysql-server mysql mysql-common mysql-libs -y
#启动
[root@hadoop03 ~]# systemctl start mysqld

#查看mysql初始化密码

 

#登陆mysql,有个(需要\转义一下
[root@hadoop03 ~]# mysql -uroot -pT2OpEi_Bw\(=p
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.4.2

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

四、docker方式安装

官网:https://download.docker.com/linux/static/stable/x86_64/

百度下载链接:链https://pan.baidu.com/s/1WyqqRmGKjKcTwjEZEn4PUQ?pwd=q8xp 提取码: q8xp

[root@hadoop03 ~]# tar -xzvf docker-19.03.15.tgz
[root@hadoop03 ~]# cp docker/* /usr/bin/
[root@hadoop03 ~]# vi /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/dockerd                 -H unix:///var/run/docker.sock                 --selinux-enabled=false                 --log-opt max-size=1g                 --default-ulimit nofile=65535:65535
ExecReload=/bin/kill -s HUP
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target

[root@hadoop03 ~]# systemctl daemon-reload
[root@hadoop03 ~]# systemctl start docker

#拉取镜像
[root@hadoop03 ~]# docker pull swr.cn-north-1.myhuaweicloud.com/iivey/mysql:8.0.23
#启动
[root@hadoop03 ~]# mkdir /dockerdata/mysql/db -p
[root@hadoop03 ~]# setenforce 0
[root@hadoop03 ~]# sed -i 's/^SELINUX=enforcing/SELINUX=Permissive/' /etc/sysconfig/selinux
[root@hadoop03 ~]# docker run -itd -p 3306:3306 --name mysql8 --restart unless-stopped -v /etc/localtime:/etc/localtime -v /dockerdata/mysql/db:/var/lib/mysql -e MYSQL_DATABASE="iivey" -e MYSQL_USER="iivey" -e MYSQL_PASSWORD="mysql123" -e MYSQL_ROOT_PASSWORD="root123" swr.cn-north-1.myhuaweicloud.com/iivey/mysql:8.0.23 --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_bin
#登陆mysql
[root@hadoop03 ~]# mysql -uroot -proot123 -h127.0.0.1
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.23 MySQL Community Server - GPL

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2034437.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

PX4二次开发快速入门

文章目录 前言一、概述二、二次开发基础(自定义工作队列,自定义uorb)三、自定义串口驱动(添加一个毫米波雷达并定高)四、自定义I2C驱动(驱动一个oled显示屏)五、自定义参数六、自定义日志七、自…

机器学习笔记:编码器与解码器

目录 介绍 组成结构 代码实现 编码器 解码器 合并编码器-解码器 思考 介绍 在机器翻译中,输入的序列与输出的序列经常是长度不相等的序列,此时,像自然语言处理这种直接使用循环神经网络或是门控循环单元的方法就行不通了。因此&#x…

Qt 窗口:菜单、工具与状态栏的应用

目录 引言: 1. 菜单栏 1.1 创建菜单栏 1.2 在菜单栏中添加菜单 1.3 创建菜单项 1.4 在菜单项之间添加分割线 1.5 综合示例 2.工具栏 2.1 创建工具栏 2.2 设置停靠位置 2.3 设置浮动属性 2.4 设置移动属性 3. 状态栏 3.1 状态栏的创建 3.2 在状态栏中显…

Pytorch_cuda版本的在线安装命令

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 运行效果如下: 这个方法是直接从pytorch官网进行在线下载和安装。 cu121,表示当前您安装的cuda版本是12.1

java基础概念15-字符串

public static void main(String[] args) {String name "张三";name "李四";System.out.println(name);// 李四} name变量是一个引用变量,它存储的是对字符串对象的引用(即内存地址),而不是字符串对象本身的…

【Git】远程仓库新建分支后,拉到本地开发

1. 在远程仓库上创建分支 2. git fetch origin:在本地同步远程仓库的分支(获取远程仓库所有分支的所有修改) 3. git remote -a:查看所有分支(远程+本地) 4. git checkout -b 本地名 远程仓库…

华夏erp2.3代码审计

1 sql注入代码 该项目使用的是Mybits的数据库,直接在*.xml文件中全局搜索 ${我们选一个比较有可能有注入的 UserMapperEx.xml 进行查 看 回溯到UserMapperEx.java。 继续回溯到UserService.java。 继续回溯可以看到UserComponent.java中userName的值是从search中获取的。 在s…

CodeWave--创建实体与枚举

一、实体的创建 可视化开发左侧边栏选择数据模块,在实体菜单下,选择2处的“” ,即可创建一个默认的实体类,修改3处的实体名称,再在实体页签中,添加所需的字段即可。 注:id是自动生成的主键&…

域名是什么?1分钟快速了解

任何一个互联网上的设备,包括服务器或我们的个人电脑设备,都有一个对应的地址,即IP地址,(比如,192.168.1.1)。所有设备,都通过这个独立唯一的IP地址来互相访问。 由于IP地址不容易被记忆&#…

仅需三步,轻松制作电脑系统安装盘!

系统安装在现在可谓是必不可少的技能。自己系统坏了,不用到电脑安装,省了不少大洋,在朋友面前也可以装装大神,百利无一害呀,还不赶快学起来! 按照以前常规方式,每个电脑系统都会配有一个光盘,然后放到光驱里面读取安装,但随着笔记本越做越薄,光驱慢慢被取消了。所以…

广州网站建设运营团队

广州是中国南部的一座国际化大都市,拥有众多创新科技企业和互联网公司。随着数字经济的快速发展,网站建设和运营已经成为企业发展和推广的重要手段。作为一支专业的网站建设运营团队,我们深知在这个信息化时代,拥有一个优质的网站…

React 学习——react项目中加入echarts图

实现的代码如下: import * as echarts from echarts import { useEffect, useRef } from react; const Home ()>{const chartRef useRef(null);useEffect(()>{// const chartDom document.getElementById(main);//使用id获取节点const chartDom chartRef…

Linux系统驱动(十六)platform驱动

文章目录 一、简介(一)device、bus、driver模型(二)platform驱动原理 二、platform总线驱动的API(一)设备信息端(二)设备驱动端(三)驱动中获取设备信息函数&a…

【子豪兄】精讲CS231N斯坦福计算机视觉公开课学习笔记

wx 搜索 gzh 司南锤,回复 子豪兄231笔记 可获取笔记文件(pdfdoc) 文章目录 学习链接:- 斯坦福大学公开课- 计算机视觉发展历史- 图像分类算法- 线性分类、损失函数与梯度下降- 神经网络与反向传播- 卷积神经网络- 可视化卷积神经网络- 训练神经网络 &…

关于WMS仓储管理系统的开发与应用

在当今这个全球化与数字化交织并进的时代,高效的仓储管理已经跃升为企业运营效能与市场竞争力提升的关键驱动力。仓库,这一供应链体系中的核心枢纽,其角色已远远超越了简单的货物存储功能,而是成为了推动货物流转效率与精准度的战…

软件测试之面试常见问题大全

软件测试之常见软件测试面试题 面试题解读,轻轻松松过面试,我以一个过来人的身份,写下这篇面试常见问题 1. 最常见的就是,为什么想进本公司,你了解本公司的业务吗? 再回答这个问题的时候是灵活的&#x…

DHCP学习笔记

1.DHCP快速配置 1.1配置接口IP R1: sysname R1 undo info-center enable interface Ethernet0/0/0 ip address 192.168.1.1 255.255.255.0 quit 1.2开启DHCP服务,接着在R1的e0/0/0配置DHCP Server功能 dhcp enable #全局下开启DHCP服务 interface Ethernet…

深度强化学习,模型改进

深度强化学习:DQN、PPO、DDPG、A3C、TD3、SAC、Rainbow、MADDPG、模仿学习,提供创新点,实验对比,代文章、润色 代码不收敛 菲涅尔模型 python深度学习算法模型定制

事务消息使用及方案选型思考

1. 事务消息概念与重要性 1.1 分布式系统中的事务问题 在分布式系统中,事务的一致性是一个核心问题。以电商登录送积分活动为例,用户登录成功后,系统需要执行两个关键操作:记录登录日志和发放积分。这两个操作需要保持一致性&am…

高性能的 C++ Web 开发框架 CPPCMS + WebSocket 模拟实现聊天与文件传输案例。

1. 项目结构 2. config.json {"service": {"api": "http","port": 8080,"ip": "0.0.0.0"},"http": {"script": "","static": "/static"} }3. CMakeLists.txt…