CentOS Linux 7系统中离线安装MySQL5.7步骤

news2024/10/5 21:19:36

预计数据文件存储目录为:/opt/mysql/data

1、文件下载:

安装文件下载链接:https://downloads.mysql.com/archives/community/

2、检查当前系统是否安装过MySQL

[root@cnic51 mysql]# rpm -qa|grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@cnic51 mysql]# sudo rpm -e --nodeps mariadb-libs
警告:/etc/my.cnf 已另存为 /etc/my.cnf.rpmsave
[root@cnic51 mysql]# rpm -qa|grep mariadb
[root@cnic51 mysql]#

3、将MySQL安装包拷贝到linux服务器的/opt/temp/目录下

[root@hadoop54 temp]# ll
总用量 570706
-rw-r--r-- 1 root root  570705920 6月  20 13:45 mysql-5.7.44-1.el7.x86_64.rpm-bundle.tar [root@hadoop54 temp]#

4、解压MySQL安装包

[root@cnic51 temp]# tar -xvf mysql-5.7.44-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-5.7.44-1.el7.x86_64.rpm
mysql-community-common-5.7.44-1.el7.x86_64.rpm
mysql-community-devel-5.7.44-1.el7.x86_64.rpm
mysql-community-embedded-5.7.44-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.44-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.44-1.el7.x86_64.rpm
mysql-community-libs-5.7.44-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.44-1.el7.x86_64.rpm
mysql-community-server-5.7.44-1.el7.x86_64.rpm
mysql-community-test-5.7.44-1.el7.x86_64.rpm
[root@cnic51 temp]#

5、在安装目录下执行rpm安装,按顺序安装

[root@cnic51 temp]# sudo rpm -ivh mysql-community-common-5.7.44-1.el7.x86_64.rpm
警告:mysql-community-common-5.7.44-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-common-5.7.44-1.e################################# [100%]
[root@cnic51 temp]# sudo rpm -ivh mysql-community-libs-5.7.44-1.el7.x86_64.rpm
警告:mysql-community-libs-5.7.44-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-libs-5.7.44-1.el7################################# [100%]
[root@cnic51 temp]# sudo rpm -ivh mysql-community-libs-compat-5.7.44-1.el7.x86_64.rpm
警告:mysql-community-libs-compat-5.7.44-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-libs-compat-5.7.4################################# [100%]
[root@cnic51 temp]# sudo rpm -ivh mysql-community-client-5.7.44-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.44-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-client-5.7.44-1.e################################# [100%]
[root@cnic51 temp]# sudo rpm -ivh mysql-community-server-5.7.44-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.44-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-server-5.7.44-1.e################################# [100%]
[root@cnic51 temp]#

6、修改/etc/my.cnf文件中datadir指向的目录下的所有内容,如果有内容的情况下:
查看datadir的值,将其修改为如下:

旧的内容为:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

新的内容为:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
skip-name-resolve
basedir=/opt/mysql
datadir=/opt/mysql/data
max_connections=2000
port=3306
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
explicit_defaults_for_timestamp=true
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/opt/mysql/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

删除/var/lib/mysql目录下的所有内容(如果指定的目录不是默认的可以不用管):
[root@hadoop54 mysql]# cd /var/lib/mysql
[root@hadoop54 mysql]# ls
[root@hadoop54 mysql]# sudo rm -rf *
[root@hadoop54 mysql]#

7、初始化数据库

[root@hadoop51 mysql]# sudo chown -R mysql:mysql /opt /mysql
[root@hadoop51 mysql]# sudo mysqld --initialize --user=mysql
[root@hadoop51 mysql]#

8、查看临时生成的root帐号密码
2024-06-20T06:17:53.912194Z 0 [ERROR] Can't find error-message file '/opt/mysql/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2024-06-20T06:17:54.145587Z 0 [Warning] InnoDB: New log files created, LSN=45790
2024-06-20T06:17:54.220326Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-06-20T06:17:54.287423Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d45d6ffd-2ecc-11ef-a74a-fa081328b000.
2024-06-20T06:17:54.295842Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-06-20T06:17:55.180876Z 0 [Warning]
2024-06-20T06:17:55.180891Z 0 [Warning]
2024-06-20T06:17:55.184006Z 0 [Warning] CA certificate ca.pem is self signed.
2024-06-20T06:17:55.315891Z 1 [Note] A temporary password is generated for root@localhost: 8<A.-MrijeiF

9、启动MySQL数据库
[root@hadoop51 mysql]#  sudo systemctl start mysqld

10、登录MySQL数据库

[root@cnic51 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44

Copyright (c) 2000, 2023, 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> set password = password("123456");
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'dev'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'dev'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>

必须先修改root用户的密码,否则执行其他的操作会报错
mysql> set password = password("123456");
Query OK, 0 rows affected, 1 warning (0.00 sec)

11、根据需要是否修改mysql库下的user表中的root用户允许任意ip连接
mysql> update mysql.user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

新建账号及授权语句:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'dev'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'dev'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

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

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

相关文章

【机器学习】---无监督学习

引言 在机器学习的广阔领域中&#xff0c;无监督学习扮演着至关重要的角色。不同于有监督学习&#xff0c;无监督学习处理的是没有标签的数据集&#xff0c;即我们不知道每个数据点的正确答案或分类。然而&#xff0c;这并不意味着无监督学习无法为我们提供有价值的信息。相反…

android 彩虹进度条自定义view实现

实现一个彩虹色进度条功能&#xff0c;不说明具体用途大家应该能猜到。想找别人造的轮子&#xff0c;但是没有合适的&#xff0c;所以决定自己实现一个。 相关知识 android 自定义view LinearGradient 线性渐变 实现步骤 自定义view 自定义一个TmcView类继承View 重写两…

Python+appium 自动化测试-Android 端环境配置

一、安装配置 JDK 一、安装环境 1、本机系统&#xff1a;Windows 10&#xff08;64 位&#xff09; 2、JDK 版本&#xff1a;1.8&#xff08;64 位&#xff09; 二、下载安装 1、JDK 和 JRE 简介 Java 环境分 JDK 和 JRE &#xff0c;JDK 就是 Java Development Kit。简单…

第 三 方 组 件 e l e m e n t - u i[Vue]

一、组件之间的传值 组件可以由内部的Data提供数据&#xff0c;也可以由父组件通过prop的方式传值。 兄弟组件之间可以通过Vuex等统一数据源提供数据共享 第一种 Movie.vue <template><div><h1>我才不要和你做朋友</h1></div></template&…

.NET C# 操作Neo4j图数据库

.NET C# 操作Neo4j图数据库 目录 .NET C# 操作Neo4j图数据库环境Code 环境 VisualStudio2022 .NET 6 Neo4j.Driver 5.21 Code // 连接设置 var uri "bolt://localhost:7687"; var user "neo4j"; var password "password"; // 请替换为你的…

丹尼尔·T·琼斯:精益生产到底是什么?

本文摘要自《精益思想》、《改变世界的机器》作者之一丹尼尔T琼斯的文章。丹尼尔T琼斯是一位学者、英国作家和研究员。他曾多次获得瑞士山吉奥卓越运营奖研究与专业出版类别的奖项&#xff0c;也包括了国际精益六西格玛研究所&#xff08;ILSSI&#xff09;[1]的"精益思想…

ChatGPT在社工攻击和反钓鱼中的应用

概述 ChatGPT是一种基于神经网络的自然语言处理模型&#xff0c;可以生成自然流畅的文本或对话。在钓鱼攻击中&#xff0c;攻击者可以使用ChatGPT生成虚假电子邮件或消息&#xff0c;更好地伪装成受害者所信任的个人或组织&#xff0c;从而获取受害者的个人信息。这种行为对个…

网络编程(一)基本概念

文章目录 一、概念&#xff08;一&#xff09;网络发展阶段1. ARPAnet阶段2. TCP/IP两个协议阶段3. 网络体系结构和OSI开放系统互联模型4. TCP/IP协议簇体系结构&#xff08;1&#xff09; 应用层&#xff1a;&#xff08;2&#xff09;传输层&#xff1a;&#xff08;3&#x…

vue3面试题八股集合——2024

vue3比vue2有什么优势&#xff1f; 性能更好&#xff0c;打包体积更小&#xff0c;更好的ts支持&#xff0c;更好的代码组织&#xff0c;更好的逻辑抽离&#xff0c;更多的新功能 描述Vu3生命周期 Options API的生命周期&#xff1a; beforeCreate: 在实例初始化之后、数据观…

NSSCTF-Web题目11

目录 [鹤城杯 2021]EasyP 1、题目 2、知识点 3、思路 [SWPUCTF 2022 新生赛]numgame 1、题目 2、知识点 3、思路 [鹤城杯 2021]EasyP 1、题目 2、知识点 php代码审计 3、思路 打开题目&#xff0c;出现一段代码&#xff0c;我们对代码进行审计 这里出现了很多不懂的…

VBA学习(14):给1000个文件重命名

如下图所示&#xff0c;一个文件夹内包含了大量文件&#xff0c;现在需要在每个文件前面增加前缀"星光牌-" 为了使代码更具有通用性&#xff0c;更方便大家使用&#xff0c;我们还是采用两步走的方式。 首先&#xff0c;使用以下代码&#xff0c;将该文件夹内的文件…

数据结构:3.3.4遍历应用例子

应用例子一&#xff1a; 改一下先序遍历的程序 例子二&#xff1a;求二叉树的高度 怎么求&#xff1f;树是递归定义的&#xff0c;所以思考求二叉树高度能不能用递归做。 二叉树的高度和左右高度有什么关系&#xff1f;二叉树的高度等于左右子树的最大高度加上一 求树高的前…

废品回收小程序的优势?有什么开发功能?

随着环保意识的增强&#xff0c;废品回收市场备受大众关注。我国是人口大国&#xff0c;回收市场拥有巨大的发展空间&#xff0c;对于商家来说&#xff0c;废品回收市场的利润空间也非常大。 在科技快速发展时代&#xff0c;为促进我国资源回收利用&#xff0c;让居民便捷回收…

开发环境安装---Visual Studio Code

开发环境安装---Visual Studio Code 1.官网下载Visual Studio Code2.安装步骤3.安装插件 1.官网下载Visual Studio Code VScode: https://code.visualstudio.com/ Visual Studio Code 简称 VSCode &#xff0c;2015 年由微软公司发布。可用于 Windows&#xff0c;macOS 和 Li…

pycharm不能安装包的解决方法

一直使用VScode写python&#xff0c;最近使用pycharm&#xff0c;但是pycharm不能安装包&#xff0c;类似这种 后面直接使用ALT F12跳转终端&#xff1a; pip install 需要添加的包 -i https://pypi.tuna.tsinghua.edu.cn/simple不报错了

如何优雅地使用 console.log 打印数组或对象

一、背景 使用 console.log 在控制台中打印数组或者对象时&#xff0c;很多时候它们的字段都是默认关闭的&#xff0c;需要手动一个个的点开&#xff0c;非常不直观且麻烦。 二、解决方案 使用 JSON.stringify() 的第三个参数 我们来看一下官方对于 JSON.stringify 的介绍 三、…

【SQL每日一练】HackerRan-Basic Join-Challenges练习

文章目录 题目题析题解1.sqlserver 题目 编写一个查询来打印 hacker _ id、 name 和每个学生创建的挑战的总数。按照挑战的总数按降序对结果进行排序。如果不止一个学生创建了相同数量的挑战&#xff0c;那么按 hacker _ id 对结果进行排序。如果不止一个学生创建了相同数量的…

NGINX_十二 nginx 地址重写 rewrite

十二 nginx 地址重写 rewrite 1 什么是Rewrite Rewrite对称URL Rewrite&#xff0c;即URL重写&#xff0c;就是把传入Web的请求重定向到其他URL的过程。URL Rewrite最常见的应用是URL伪静态化&#xff0c;是将动态页面显示为静态页面方式的一种技术。比如 http://www.123.com…

odoo 入库发票三大凭证

注意对应科目 库存计价凭证 原材料 成品 供应商账单凭证 银行账单凭证