歐拉服務器操作系統安裝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.pswp.cn/bicheng/77197.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/77197.shtml
英文地址,請注明出處:http://en.pswp.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.…