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

预计数据文件存储目录为:/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.mzph.cn/news/856781.shtml

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

相关文章

详释 Promise

当涉及到处理异步操作时&#xff0c;JavaScript 中的 Promise 是一个非常强大且常用的工具。下面详细解释 Promise 的相关内容&#xff0c;并举例说明&#xff1a; 1. 解决回调地狱的问题 Promise 的链式调用风格可以有效解决回调地狱的问题&#xff0c;使得代码更加清晰和易…

xss-lab靶场level1-level10

level1&#xff1a; 无过滤形式 直接 <script>window.alert(123)</script> level2: htmlspecialchars函数将预定义的小于和大于号转换为html实体 < &#xff08;小于&#xff09;成为 < > &#xff08;大于&#xff09;成为 > 源代码 <?…

深入探索Llama 2:下一代开源语言模型的革新与影响

Llama 2是Meta AI发布的一款先进的开源大模型&#xff0c;属于大型语言模型&#xff08;LLM&#xff09;类别。它是Transformer架构的一种变体&#xff0c;经过预先训练并在多种文本和代码数据集上进行微调&#xff0c;旨在提升功能和安全性。Llama 2的关键特点包括&#xff1a…

06. 多线程 yield 方法

1. 前言 本节对 yield 方法进行深入的剖析&#xff0c;主要内容点如下&#xff1a; 首先要了解什么是 CPU 执行权&#xff0c;因为 yield 方法与 CPU 执行权息息相关&#xff1b;了解 yield 方法的作用&#xff0c;要明确 yield 方法的使用所带来的运行效果&#xff1b;了解什…

简述http/https、tcp/ip、SSL/TLS介绍

HTTP/HTTPS、TCP和IP之间的区别主要体现在它们的作用层次、功能特点以及在网络通信中的角色。 一. 作用层次&#xff1a; HTTP/HTTPS&#xff1a;HTTP&#xff08;Hyper Text Transfer Protocol&#xff0c;超文本传输协议&#xff09;和HTTPS&#xff08;HTTP Secure&#x…

跨区域文件管控解决方案,一文了解

跨区域文件管控是一个涉及在不同地域或区域之间管理和控制文件的过程&#xff0c;它包括安全性、合规性和管理效率等多个方面。以下是一些关键的考量因素&#xff1a; 1.安全性&#xff1a;确保在传输过程中文件不被截获、篡改或泄露。使用加密技术保护文件&#xff0c;并确保传…

云呼叫中心系统能帮企业做哪些事?

在云计算时代大环境的影响&#xff0c;各大企业也都企图将云计算融入企业业务中&#xff0c;智能化不只可以提高企业产能、提高服务效率&#xff0c;更能发掘更高的品牌价值。云计算不断深入企业内部&#xff0c;尤其在劳动密集型的产业中&#xff0c;优势更加明显。以电销为例…

mysql 慢sql优化记录

最近在分析一条SQL&#xff0c;这条SQL执行时间去到2秒以上。SQL如下&#xff1a; selectcount(d.id) fromt_msg d whered.userid12456 and d.isread0 AND d.msgnumber<> NEW-JCPT003 表上索引有 idx_userid(userid)&#xff0c;这条SQL是一条比较标准的统计…

【初阶数据结构】深入解析带头双向循环链表:探索底层逻辑

&#x1f525;引言 本篇将介绍带头双向循环链表底层实现以及在实现中需要注意的事项&#xff0c;帮助各位在使用过程中根据底层实现考虑到效率上问题和使用时可能会导致的错误使用 &#x1f308;个人主页&#xff1a;是店小二呀 &#x1f308;C语言笔记专栏&#xff1a;C语言笔…

昇腾Ascend C算子开发

Ascend C的算子实现主要包含两个部分&#xff1a; ● Host侧Tiling实现 由于NPU中AI Core内部存储无法完全容纳算子输入输出的所有数据&#xff0c;需要每次搬 运一部分输入数据进行计算然后搬出&#xff0c;再搬运下一部分输入数据进行计算&#xff0c;这个 过程就称之为Tilin…

C#使用NPOI库实现Excel的导入导出操作——提升数据处理效率的利器

文章目录 一、NPOI库简介二、安装与引入三、Excel的导入操作1.CSV格式导入2.XLS格式导入3. XLSX格式导入 四、Excel的导出操作1. CSV格式导出2. XLS格式导出3. XLSX格式导出 五、NPOI库的应用优势与改进方向总结 在日常工作学习中&#xff0c;我们经常需要处理Excel文件&#x…

AIX小机环境如何给ASM添加磁盘

前面几篇介绍了HPUX,Solaris平台上RAC集群ASM如何添加磁盘的 &#xff0c;三大UNIX平台只差AIX&#xff0c;本文介绍AIX平台RAC 添加ASM磁盘 environment&#xff1a; AIX 6.1 oracle 10.0.2.4 2 nodes RAC (storage HP-6100 FC disk) 1. 存储划盘&#xff0c;并将盘赋予…

[Day 16] 區塊鏈與人工智能的聯動應用:理論、技術與實踐

計算機視覺技術在AI中的應用 簡介 計算機視覺&#xff08;Computer Vision&#xff0c;CV&#xff09;是人工智能&#xff08;AI&#xff09;中一個重要且快速發展的領域&#xff0c;它使得機器能夠理解和解釋視覺信息。隨著硬件計算能力的提升和深度學習方法的興起&#xff…

紫光展锐芯片进入烧录模式

实验平台&#xff1a;移远通信SC200L搭载SMART-EVB-G5开发板 软件进入&#xff1a; SPRD平台芯片可以通过adb进入fastboot模式&#xff0c;由fastboot flash boot等指令烧录&#xff1a; $ adb root $ adb reboot fastboot $ fastboot flash boot boot.img 由于usb传输一般都…

探索 Spring Boot 集成缓存功能的最佳实践

在线工具站 推荐一个程序员在线工具站&#xff1a;程序员常用工具&#xff08;http://cxytools.com&#xff09;&#xff0c;有时间戳、JSON格式化、文本对比、HASH生成、UUID生成等常用工具&#xff0c;效率加倍嘎嘎好用。 程序员资料站 推荐一个程序员编程资料站&#xff1a;…

《单元测试之道Java版——使用JUnit》学习笔记汇总

前言 主要用来记录《单元测试之道Java版——使用JUnit》书中的一些必要知识&#xff0c;方便后期编程使用。 目录 序言你的首个单元测试使用Junit编写测试测试哪些内容&#xff1a;Right-BICEPCORRECT边界条件使用Mock对象好的测试所具有的品质在项目中进行测试设计话题 后…

使用kibana创建索引的时候报错处理

报错信息&#xff1a;The index pattern youve entered doesnt match any indices. You can match your 1 index, below. 使用kibana创建索引的时候&#xff0c;无法进行下一步创建操作&#xff0c;出现这种情况有很多种情况&#xff0c;每个人遇到的问题会不一样。 第一种&am…

python基础篇(3):print()补偿知识点

1 print输出不换行 默认print语句输出内容会自动换行&#xff0c;如下&#xff1a; print("hello") print(" world") 结果&#xff1a; 在print语句中&#xff0c;加上 end’’ 即可输出不换行了 print("hello",end) print(" world&quo…

Java | Leetcode Java题解之第171题Excel表列序号

题目&#xff1a; 题解&#xff1a; class Solution {public int titleToNumber(String columnTitle) {int number 0;int multiple 1;for (int i columnTitle.length() - 1; i > 0; i--) {int k columnTitle.charAt(i) - A 1;number k * multiple;multiple * 26;}ret…

Python重力弹弓流体晃动微分方程模型和交直流电阻电容电路

&#x1f3af;要点 &#x1f3af;计算地球大气层中热层金属坠物运动轨迹 | &#x1f3af;计算炮弹最佳弹射角度耦合微分方程 | &#x1f3af;计算电磁拉莫尔半径螺旋运动 | &#x1f3af;计算航天器重力弹弓运动力学微分方程 | &#x1f3af;计算双摆的混沌运动非线性微分方程…