欧拉服务器操作系统安装MySQL

1. 安装MySQL服务器​​

1. 更新仓库缓存

sudo dnf makecache

2. 安装MySQL

sudo dnf install mysql-server

2. 初始化数据库​

sudo mysqld --initialize --user=mysql

3. 启动数据库服务

# 启动服务
sudo systemctl start mysqld# 设置开机自启
sudo systemctl enable mysqld# 检查状态
sudo systemctl status mysqld

4. 获取初始临时密码​​

MySQL首次启动后会生成临时root密码:

[root@koji-builder local]# cat /var/log/mysql/mysqld.log 
2025-04-15T03:47:19.698504Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.26) initializing of server in progress as process 501966
2025-04-15T03:47:19.707644Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-04-15T03:47:20.097607Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-04-15T03:47:21.185380Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-04-15T03:47:21.185792Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-04-15T03:47:21.335996Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2025-04-15T03:47:24.352442Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.26) starting as process 502015
2025-04-15T03:47:24.360719Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-04-15T03:47:24.454276Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-04-15T03:47:24.663767Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-04-15T03:47:24.664110Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-04-15T03:47:24.666148Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2025-04-15T03:47:24.666287Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2025-04-15T03:47:24.683037Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/lib/mysql/mysqlx.sock
2025-04-15T03:47:24.683165Z 0 [System] [MY-010931] [Server] /usr/libexec/mysqld: ready for connections. Version: '8.0.26'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution.
2025-04-15T03:50:47.632895Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.26).
2025-04-15T03:50:48.933911Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.26)  Source distribution.
2025-04-15T03:51:01.921293Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.26) initializing of server in progress as process 502402
2025-04-15T03:51:01.937221Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-04-15T03:51:02.314323Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-04-15T03:51:03.280084Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-04-15T03:51:03.280364Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-04-15T03:51:03.328444Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: V8xP0pUmup?J

1.如果初始化后没有生成密码需要重新初始化

1.步骤 1: 停止 MySQL 服务​​

sudo systemctl stop mysqld

​​ 2: 清理残留数据(谨慎操作!)​​

# 确保是全新安装且无需保留数据
sudo rm -rf /var/lib/mysql/*

​​ 3: 重新初始化数据库​​

sudo mysqld --initialize --user=mysql
#此命令会生成新的临时密码并输出到日志文件。

4: 启动服务并查看日志​​

sudo systemctl start mysqld
sudo grep 'temporary password' /var/log/mysqld.log

5. 使用临时密码登录​

[root@koji-builder local]# mysql -u root -p'V8xP0pUmup?J'
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 10
Server version: 8.0.26Copyright (c) 2000, 2021, 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>

6. 首次登录后强制修改密码​

修改 root 密码(需满足复杂度要求,如大小写字母、数字、符号)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'yuhua@24';
Query OK, 0 rows affected (0.00 sec)

7. 运行安全加固脚本​

[root@koji-builder local]# sudo mysql_secure_installation Securing the MySQL server deployment.Enter password for user root: VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?Press y|Y for Yes, any other key for No: yThere are three levels of password validation policy:LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.Estimated strength of the password: 50 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y- Dropping test database...
Success.- Removing privileges on test database...
Success.Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.All done! 
按提示操作:输入新设置的 root 密码。
移除匿名用户(选 Y)。
禁止远程 root 登录(选 Y)。
删除测试数据库(选 Y)。
刷新权限表(选 Y)。

8. 登录数据库

[root@koji-builder local]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.26 Source distributionCopyright (c) 2000, 2021, 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.mzph.cn/bicheng/77197.shtml

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

相关文章

SQLark:一款国产免费数据库开发和管理工具

SQLark&#xff08;百灵连接&#xff09;是一款面向信创应用开发者的数据库开发和管理工具&#xff0c;用于快速查询、创建和管理不同类型的数据库系统&#xff0c;目前可以支持达梦数据库、Oracle 以及 MySQL。 对象管理 SQLark 支持丰富的数据库对象管理功能&#xff0c;包括…

Spring Boot 中的自动配置原理

2025/4/6 向全栈工程师迈进&#xff01; 一、自动配置 所谓的自动配置原理就是遵循约定大约配置的原则&#xff0c;在boot工程程序启动后&#xff0c;起步依赖中的一些bean对象会自动的注入到IOC容器中。 在讲解Spring Boot 中bean对象的管理的时候&#xff0c;我们注入bean对…

Mysql8配置文件

Mysql8配置文件 修改my.cnf----配置持久化键(persistence key)配置表名不区分大小写 修改my.cnf----配置持久化键(persistence key) MySQL8初始化数据库之前配置好这些变量值&#xff0c;初始化数据库之后可能无法修改这个值。 # 服务端配置 [mysqld] ######## 数据目录和基…

关于系统架构思考,如何设计实现系统的高可用?

绪论、系统高可用的必要性 系统高可用为了保持业务连续性保障&#xff0c;以及停机成本量化&#xff0c;比如在以前的双十一当天如果出现宕机&#xff0c;那将会损失多少钱&#xff1f;比如最近几年Amazon 2021年30分钟宕机损失$5.6M。当然也有成功的案例&#xff0c;比如异地…

【Unity笔记】实现可视化配置的Unity按键输入管理器(按下/长按/松开事件 + UnityEvent绑定)

【Unity笔记】实现可视化配置的Unity按键输入管理器 适用于角色控制、技能触发的Unity按键输入系统&#xff0c;支持UnityEvent事件绑定、长按/松开监听与启用开关 一、引言 在 Unity 游戏开发中&#xff0c;处理键盘输入是最常见的交互方式之一。尤其是角色控制、技能释放、菜…

Fortran 中使用 C_LOC 和 C_F_POINTER 结合的方法来实现不同类型指针指向同一块内存区域

在 Fortran 中&#xff0c;可以使用 C_LOC 和 C_F_POINTER 结合的方法来实现不同类型指针指向同一块内存区域。以下是具体方法和示例&#xff1a; 关键步骤&#xff1a; 获取内存地址&#xff1a;用 C_LOC 获取原始数组的 C 地址。类型转换&#xff1a;用 C_F_POINTER 将地址转…

Spring Boot整合Kafka的详细步骤

1. 安装Kafka 下载Kafka&#xff1a;从Kafka官网下载最新版本的Kafka。 解压并启动&#xff1a; 解压Kafka文件后&#xff0c;进入bin目录。 启动ZooKeeper&#xff1a;./zookeeper-server-start.sh ../config/zookeeper.properties。 启动Kafka&#xff1a;./kafka-server-…

【含文档+PPT+源码】基于微信小程序的学校体育馆操场预约系统的设计与实现

课程简介&#xff1a; 本课程演示的是一款基于微信小程序的学校体育馆操场预约系统的设计与实现&#xff0c;主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的 Java 学习者。 1.包含&#xff1a;项目源码、项目文档、数据库脚本、软件工具等所有资料 2.带你从…

【Leetcode-Hot100】最大子数组和

题目 解答 class Solution(object):def maxSubArray(self, nums):""":type nums: List[int]:rtype: int"""len_nums len(nums)result -1e5left_fit, right_fit 0, len_nums-1if len_nums 1:return nums[0]sum_left, sum_right 0, 0while r…

txt、Csv、Excel、JSON、SQL文件读取(Python)

txt、Csv、Excel、JSON、SQL文件读取&#xff08;Python&#xff09; txt文件读写 创建一个txt文件 fopen(rtext.txt,r,encodingutf-8) sf.read() f.close() print(s)open( )是打开文件的方法 text.txt’文件名 在同一个文件夹下所以可以省略路径 如果不在同一个文件夹下 ‘…

硬件电路设计之51单片机(2)

声明&#xff1a;绘制原理图和PCB的软件为嘉立创EDA。根据B站尚硅谷嵌入式之原理图&PCB设计教程学习所作个人用笔记。 目录 一、原理图详解 1、TypeC接口 &#xff08;1&#xff09;TypeC接口介绍 &#xff08;2&#xff09;TypeC原理图 2、5V转3.3V 3、单片机电源开…

kubernetes 入门篇之架构介绍

经过前段时间的学习和实践&#xff0c;对k8s的架构有了一个大致的理解。 1. k8s 分层架构 架构层级核心组件控制平面层etcd、API Server、Scheduler、Controller Manager工作节点层Kubelet、Kube-proxy、CRI&#xff08;容器运行时接口&#xff09;、CNI&#xff08;网络插件&…

Flink CDC 出现错误码 1236 和 SQL 状态 HY000 的原因及解决方法

Flink CDC 出现错误码 1236 和 SQL 状态 HY000 的原因及解决方法 常见原因 server-id 冲突:当多个 Flink CDC 任务连接同一个 MySQL 实例,且使用了相同的 server-id 时,会导致该冲突。因为 MySQL 服务器通过 server-id 来区分不同的从服务器,如果多个 Flink CDC 任务使用相…

从PPT到PNG:Python实现的高效PPT转图工具

从PPT到PNG&#xff1a;Python实现的高效PPT转图工具 在日常工作中&#xff0c;PPT&#xff08;PowerPoint&#xff09;文件是我们常用的演示工具。然而&#xff0c;有时候我们需要将PPT的内容提取为图片格式&#xff08;如PNG&#xff09;以便于展示或保存。手动将每一页PPT保…

【开发语言】悬空指针问题

悬空指针&#xff08;Dangling Pointer&#xff09;是编程中常见的内存管理问题&#xff0c;尤其在C/C这类手动管理内存的语言中。以下是详细解释&#xff1a; 什么是悬空指针&#xff1f; 悬空指针是指向已经被释放&#xff08;或失效&#xff09;内存的指针。这段内存可能已…

【持续更新中】常用docker服务部署指北

前言 docker是个好东西&#xff0c;小树莓派上也能快速部署&#xff0c;方便管理环境。用这篇笔记来记录下各种软件的快速部署方式 准备环境 docker安装 curl -fsSL https://get.docker.com -o get-docker.sh sh ./get-docker.shdocker镜像源配置 一种方法是设置proxy&…

Godot学习-创建简单动画

文章目录 1、准备工作Godot资源 2、创建项目3、创建结点4、创建动画1、创建动画2、添加轨道3、创建关键帧3.1 第一个关键帧3.2 第二个关键帧 5、加载后自动播放6、动画循环7、轨道设置1、轨道更新模式2、轨迹插值3、其他属性的关键帧4、编辑关键帧5、使用 RESET 轨道6、洋葱皮 …

Python 爬虫解决 GBK乱码问题

文章目录 前言爬取初尝试与乱码问题编码知识科普UTF - 8GBKUnicode Python中的编码转换其他编码补充知识GBKGB18030GB2312UTF&#xff08;UCS Transfer Format&#xff09;Unicode 总结 前言 在Python爬虫的过程中&#xff0c;我尝试爬取一本小说&#xff0c;遇到GBK乱码问题&a…

B站搜索关键词机制深度解析:算法逻辑与优化策略

在拥有超过5亿用户的B站生态系统中&#xff0c;每天都有海量的视频内容被上传和消费。对于创作者而言&#xff0c;如何让自己的视频在茫茫内容海洋中被目标受众发现&#xff0c;是至关重要的课题。而关键词&#xff0c;正是连接内容与用户的关键桥梁。理解B站的搜索关键词机制&…

宝塔面板中解锁Laravel日志查看的奥秘

目录 一、前言二、Laravel 日志基础认知2.1 日志的作用2.2 Laravel 日志的默认配置 三、查找 Laravel 日志文件位置3.1 常规存储路径3.2 自定义路径查找 四、查看 Laravel 日志内容4.1 宝塔面板文件管理器查看4.2 使用命令行查看 五、常见问题及解决方法5.1 权限不足无法查看5.…