Linux环境部署MySQL

devtools/2024/9/25 3:55:02/

LINUX环境下部署MySQL

MySQL官网:https://www.mysql.com/
MySQL是一种关系型数据库管理系统,所使用的 SQL 语言是用于访问数据库的最常用标准化语言。MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点。本文采用社区版进行测试学习MySQL。

一、准备安装包

在该目录下再创建一个文件夹,并且将安装包解压到该文件夹中

[root@test01 soft]# ls
mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar
# 在当前目录下(mysql)下创建一个 mysql-8.0.26 文件夹
[root@test01 soft]# mkdir mysql-8.0.36 
# 解压安装包到该目录下
[root@test01 soft]# tar -xvf mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar -C mysql-8.0.36

解压完成之后可以切换到 mysql-8.0.36 目录下查看解压后的文件

[root@test01 mysql-8.0.36]# ls
mysql-community-client-8.0.36-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm
mysql-community-common-8.0.36-1.el7.x86_64.rpm
mysql-community-debuginfo-8.0.36-1.el7.x86_64.rpm
mysql-community-devel-8.0.36-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.36-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm
mysql-community-libs-8.0.36-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm
mysql-community-server-8.0.36-1.el7.x86_64.rpm
mysql-community-server-debug-8.0.36-1.el7.x86_64.rpm
mysql-community-test-8.0.36-1.el7.x86_64.rpm

二、安装RPM依赖包

解压后得到的文件都是RPM文件,需要用到RPM包资源管理器相关的指令安装RPM的安装包,安装执行RPM安装包需要一些插件,因为MySQL里面有部分RPM的安装依赖于该插件。

[root@test01 mysql-8.0.36]# yum -y install libaio perl net-tools
[root@test01 mysql-8.0.36]# yum install openssl-devel

三、安装MySQL的RPM包

安装完该插件之后,依次执行以下命令安装这些RPM包。

[root@test01 mysql-8.0.36]# rpm -ivh mysql-community-common-8.0.36-1.el7.x86_64.rpm
警告:mysql-community-common-8.0.36-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID a8d3785c: NOKEY
准备中...                          ################################# [100%]软件包 mysql-community-common-8.0.36-1.el7.x86_64 已经安装
[root@test01 mysql-8.0.36]# rpm -ivh mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm
警告:mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID a8d3785c: NOKEY
准备中...                          ################################# [100%]软件包 mysql-community-client-plugins-8.0.36-1.el7.x86_64 已经安装
[root@test01 mysql-8.0.36]# rpm -ivh mysql-community-libs-8.0.36-1.el7.x86_64.rpm
警告:mysql-community-libs-8.0.36-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID a8d3785c: NOKEY
准备中...                          ################################# [100%]软件包 mysql-community-libs-8.0.36-1.el7.x86_64 已经安装
[root@test01 mysql-8.0.36]# rpm -ivh mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm
警告:mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID a8d3785c: NOKEY
准备中...                          ################################# [100%]软件包 mysql-community-libs-compat-8.0.36-1.el7.x86_64 已经安装
[root@test01 mysql-8.0.36]# rpm -ivh mysql-community-devel-8.0.36-1.el7.x86_64.rpm
警告:mysql-community-devel-8.0.36-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID a8d3785c: NOKEY
准备中...                          ################################# [100%]软件包 mysql-community-devel-8.0.36-1.el7.x86_64 已经安装
[root@test01 mysql-8.0.36]# rpm -ivh mysql-community-client-8.0.36-1.el7.x86_64.rpm
警告:mysql-community-client-8.0.36-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID a8d3785c: NOKEY
准备中...                          ################################# [100%]软件包 mysql-community-client-8.0.36-1.el7.x86_64 已经安装
[root@test01 mysql-8.0.36]# rpm -ivh mysql-community-server-8.0.36-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.36-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID a8d3785c: NOKEY
错误:依赖检测失败:mysql-community-icu-data-files = 8.0.36-1.el7 被 mysql-community-server-8.0.36-1.el7.x86_64 需要

出现错误信息,要解决这个问题,需要先安装缺失的ICU数据文件。

[root@test01 mysql-8.0.36]# yum install mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm
已加载插件:fastestmirror, langpacks
正在检查 mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm: mysql-community-icu-data-files-8.0.36-1.el7.x86_64
mysql-community-icu-data-files-8.0.36-1.el7.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-icu-data-files.x86_64.0.8.0.36-1.el7 将被 安装
--> 解决依赖关系完成
http://mirrors.aliyun.com/centos-altarch/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
===============================================================================================Package         架构   版本         源                                                   大小
===============================================================================================
正在安装:mysql-community-icu-data-filesx86_64 8.0.36-1.el7 /mysql-community-icu-data-files-8.0.36-1.el7.x86_64 3.9 M事务概要
===============================================================================================
安装  1 软件包总计:3.9 M
安装大小:3.9 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。正在安装    : mysql-community-icu-data-files-8.0.36-1.el7.x86_64                         1/1 验证中      : mysql-community-icu-data-files-8.0.36-1.el7.x86_64                         1/1 已安装:mysql-community-icu-data-files.x86_64 0:8.0.36-1.el7                                         完毕!

安装缺失的ICU文件后重新安装mysql-community-server-8.0.36-1.el7.x86_64.rpm包。

[root@test01 mysql-8.0.36]# rpm -ivh mysql-community-server-8.0.36-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.36-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID a8d3785c: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...1:mysql-community-server-8.0.36-1.e################################# [100%]

四、启动MySQL服务

在Linux中MySQL安装好了之后系统会自动的注册一个服务,服务名称叫做 mysqld,所以可以通过以下命令操作MySQL:

  • 启动MySQL服务:systemctl start mysqld
  • 重启MySQL服务:systemctl restart mysqld
  • 关闭MySQL服务:systemctl stop mysqld
# 启动mysql服务
[root@panweidb mysql-8.0.36]# systemctl start mysqld
Redirecting to /bin/systemctl start mysqld.service

RPM安装MySQL会自动生成一个随机密码,可以在/var/log/mysqld.log这个文件中查找密码。

[root@panweidb mysql-8.0.36]# cat /var/log/mysqld.log | grep password
2024-04-18T09:24:14.608802Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: lpOagaL2hu;d

五、连接MySQL服务

[root@test01 mysql-8.0.36]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.36Copyright (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> 

为了方便后期使用需要更改初始密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Test@123';
Query OK, 0 rows affected (0.01 sec)

http://www.ppmy.cn/devtools/4326.html

相关文章

若依框架后台管理系统_修改后台管理密码

若依框架后台管理系统_修改后台管理密码 1. 找见加密函数: /*** 生成BCryptPasswordEncoder密码** param password 密码* return 加密字符串*/public static String encryptPassword(String password){BCryptPasswordEncoder passwordEncoder new BCryptPasswordE…

关于Python中install edge_tts记录

如下代码: #!/usr/bin/env python3""" Basic audio streaming example.This example shows how to stream the audio data from the TTS engine, and how to get the WordBoundary events from the engine (which could be ignored if not needed).…

PHP 爬虫如何配置代理 IP(CURL 函数)

在 PHP中 配置代理IP&#xff0c;可以通过设置 CURL 库的选项来实现&#xff0c;代码如下&#xff1a; 当然你要有代理ip来源&#xff0c;比如我用的这个 代理商 &#xff0c;如果想服务稳定不建议找开源代理池&#xff0c;避免被劫持。 <?php // 初始化cURL会话 $ch cu…

外包干了10天,技术退步明显。。。。。

先说一下自己的情况&#xff0c;本科生&#xff0c;2019年我通过校招踏入了南京一家软件公司&#xff0c;开始了我的职业生涯。那时的我&#xff0c;满怀热血和憧憬&#xff0c;期待着在这个行业中闯出一片天地。然而&#xff0c;随着时间的推移&#xff0c;我发现自己逐渐陷入…

计算公式基础

文章目录 MASMAEXMPA加权移动平均线成交量换手率MACDKDJ MA 均线一般指移动平均线。 移动平均线&#xff0c;Moving Average&#xff0c;简称MA&#xff0c;MA是用统计分析的方法&#xff0c;将一定时期内的证券价格&#xff08;指数&#xff09;加以平均&#xff0c;并把不同…

战姬物语部署

一.准备环境 #关闭seliunx和防火墙 setenforce 0 systemctl stop firewalld systemctl disable firewalld #配置源&#xff0c;并安装常用工 curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/epel.repo …

中图分类法的正则表达式参考

文章目录 1. 中图分类法2. 正则表达式3. 使用方法4. 参考 1. 中图分类法 中图分类法&#xff0c;全称为《中国图书馆图书分类法》&#xff0c;简称《中图法》&#xff0c;是中国国内普遍采用的一种图书分类体系&#xff0c;用于组织和管理图书馆藏书&#xff0c;方便读者查找和…

类和对象最终与内存管理上

嗨喽&#xff0c;大家好呀&#xff0c;今天阿鑫给大家带来类和对象最终章以及内存管理上&#xff01;经过半个多月的艰苦奋斗我们终于将要翻过类和对象这座山&#xff0c;下面让我们开始今天的博客学习吧&#xff01; 类和对象最终与内存管理上 匿名对象c内存管理方式operato…