最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux搭建單機MySQL8.0.26版本的操作方法

 更新時間:2025年05月05日 08:26:41   作者:huangSir-devops  
這篇文章主要介紹了Linux搭建單機MySQL8.0.26版本的操作方法,本文通過圖文并茂的形式給大家講解的非常詳細(xì),感興趣的朋友一起看看吧

概述

本文主要是寫Ubuntu22.04搭建MySQL8.0.26版本

環(huán)境信息

IP系統(tǒng)規(guī)格
10.0.0.10Ubuntu22.042c4g

數(shù)據(jù)庫服務(wù)安裝步驟

下載前置依賴

# 下載libtinfo5、libnuma1依賴
[root@lb ~]# apt update -y && apt install -y libtinfo5 libnuma1

服務(wù)下載

方式一:進(jìn)入官網(wǎng)下載,并上傳到宿主機中,適合離線環(huán)境

官網(wǎng)下載地址: https://downloads.mysql.com/archives/community/

方式二:直接在宿主機中使用wget進(jìn)行下載,適合宿主機聯(lián)網(wǎng)環(huán)境

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz

服務(wù)解壓并創(chuàng)建軟鏈接

# 服務(wù)解壓至家目錄
[root@lb ~]# tar -xvf mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
# 創(chuàng)建軟鏈接
[root@lb ~]# ln -s mysql-8.0.26-linux-glibc2.12-x86_64 mysql
# 查看
[root@lb ~]# ll | grep mysql
lrwxrwxrwx  1 root root        35 May  1 15:43 mysql -> mysql-8.0.26-linux-glibc2.12-x86_64/
drwxr-xr-x  9 root root      4096 May  1 15:43 mysql-8.0.26-linux-glibc2.12-x86_64/
-rw-r--r--  1 root root 914806904 Jul  2  2021 mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz

配置環(huán)境變量

# /root/mysql/bin根據(jù)你安裝的實際地址來進(jìn)行替換
[root@lb ~]# echo 'export PATH=/root/mysql/bin:$PATH' >> /etc/profile
[root@lb ~]# source /etc/profile

檢查環(huán)境變量是否配置正確

[root@lb ~]# mysql -V
mysql  Ver 8.0.26 for Linux on x86_64 (MySQL Community Server - GPL)

創(chuàng)建MySQL的虛擬用戶

[root@lb ~]# useradd -s /sbin/nologin -M mysql

創(chuàng)建數(shù)據(jù)存儲目錄,并修改目錄的擁有者

[root@lb ~]# mkdir -p /data/mysql/data
[root@lb ~]# chown -R mysql.mysql /data/mysql/data

初始化數(shù)據(jù)庫

# 初始化數(shù)據(jù)庫,沒有報錯即代表成功
[root@lb ~]# mysqld --initialize-insecure  --user=mysql  --datadir=/data/mysql/data  --basedir=/root/mysql
2025-05-01T07:59:04.638615Z 0 [System] [MY-013169] [Server] /root/mysql-8.0.26-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.26) initializing of server in progress as process 132486
2025-05-01T07:59:04.656989Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-05-01T07:59:05.254538Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-05-01T07:59:05.950015Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-05-01T07:59:05.950635Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-05-01T07:59:06.009584Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

參數(shù)解釋:

  • --initialize-insecure:不安全的初始化,表示數(shù)據(jù)庫啟動后沒有密碼信息,
  • --initialize:安全初始化,表示數(shù)據(jù)庫啟動后,會有默認(rèn)的密碼信息
  • --user:指定用戶
  • --datadir:指定數(shù)據(jù)存儲目錄
  • --basedir:指定MySQL安裝的目錄

數(shù)據(jù)庫初始化成功之后數(shù)據(jù)目錄會有以下文件

[root@lb ~]# ll /data/mysql/data/
total 177608
-rw-r----- 1 mysql mysql   196608 May  1 15:59 '#ib_16384_0.dblwr'
-rw-r----- 1 mysql mysql  8585216 May  1 15:59 '#ib_16384_1.dblwr'
drwxr-x--- 2 mysql mysql     4096 May  1 15:59 '#innodb_temp'/
drwxr-xr-x 6 mysql mysql     4096 May  1 15:59  ./
drwxr-xr-x 3 root  root      4096 May  1 15:56  ../
-rw-r----- 1 mysql mysql       56 May  1 15:59  auto.cnf
-rw------- 1 mysql mysql     1676 May  1 15:59  ca-key.pem
-rw-r--r-- 1 mysql mysql     1112 May  1 15:59  ca.pem
-rw-r--r-- 1 mysql mysql     1112 May  1 15:59  client-cert.pem
-rw------- 1 mysql mysql     1680 May  1 15:59  client-key.pem
-rw-r----- 1 mysql mysql     5995 May  1 15:59  ib_buffer_pool
-rw-r----- 1 mysql mysql 50331648 May  1 15:59  ib_logfile0
-rw-r----- 1 mysql mysql 50331648 May  1 15:59  ib_logfile1
-rw-r----- 1 mysql mysql 12582912 May  1 15:59  ibdata1
drwxr-x--- 2 mysql mysql     4096 May  1 15:59  mysql/
-rw-r----- 1 mysql mysql 26214400 May  1 15:59  mysql.ibd
drwxr-x--- 2 mysql mysql     4096 May  1 15:59  performance_schema/
-rw------- 1 mysql mysql     1676 May  1 15:59  private_key.pem
-rw-r--r-- 1 mysql mysql      452 May  1 15:59  public_key.pem
-rw-r--r-- 1 mysql mysql     1112 May  1 15:59  server-cert.pem
-rw------- 1 mysql mysql     1680 May  1 15:59  server-key.pem
drwxr-x--- 2 mysql mysql     4096 May  1 15:59  sys/
-rw-r----- 1 mysql mysql 16777216 May  1 15:59  undo_001
-rw-r----- 1 mysql mysql 16777216 May  1 15:59  undo_002

編寫MySQL配置文件

[root@lb ~]# cat /etc/my.cnf
[mysqld]
# 數(shù)據(jù)庫文件的存儲路徑
datadir=/data/mysql/data
# 服務(wù)器監(jiān)聽的端口號
port=3306
# 字符集設(shè)置
character-set-server=utf8mb4
# 排序規(guī)則
collation-server=utf8mb4_general_ci
# 允許的最大連接數(shù)
max_connections=1000
# MySQL服務(wù)器的緩存大小,用于緩存數(shù)據(jù)和索引
innodb_buffer_pool_size=1G
# 日志文件的路徑
log_error=/var/log/mysql/error.log
# 慢查詢?nèi)罩疚募穆窂?
slow_query_log_file=/var/log/mysql/slow-query.log
# 開啟慢查詢?nèi)罩荆?表示開啟,0表示關(guān)閉
slow_query_log=1
# 設(shè)定慢查詢的時間閾值,單位為秒,超過此時間的查詢將被記錄到慢查詢?nèi)罩局?
long_query_time=3
# 設(shè)置用戶
user=mysql
# 設(shè)置socket連信息
socket=/tmp/mysql.sock
[client]
# 客戶端默認(rèn)字符集
default-character-set=utf8mb4
[mysql]
# MySQL命令行工具的默認(rèn)字符集
default-character-set=utf8mb4
 

創(chuàng)建日志目錄

[root@lb ~]# mkdir -p /var/log/mysql/
[root@lb ~]# chown -R mysql.mysql /var/log/mysql/

修改MySQL安裝目錄中的啟動文件

拷貝啟動文件至/etc/init.d目錄下

[root@lb ~]# cp /root/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@lb ~]# chmod +x /etc/init.d/mysqld

修改啟動文件的內(nèi)容
vim /etc/init.d/mysqld

啟動MySQL服務(wù)

# 沒報錯即代表啟動成功
[root@lb ~]# /etc/init.d/mysqld start
Starting mysqld (via systemctl): mysqld.service.
# 檢查端口號
[root@lb ~]# ss -lntup | grep 3306
tcp   LISTEN 0      70                 *:33060            *:*    users:(("mysqld",pid=144896,fd=21))
tcp   LISTEN 0      1000               *:3306             *:*    users:(("mysqld",pid=144896,fd=24))

修改root用戶密碼

[root@lb ~]# mysqladmin -u root password "huangsir"
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

登錄MySQL服務(wù)

[root@lb ~]# mysql -uroot -phuangsir
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.26 MySQL Community Server - GPL
Copyright (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>

遠(yuǎn)程連接MySQL

MySQL默認(rèn)的root用戶是無法遠(yuǎn)程登錄的,所以我們需要創(chuàng)建一個用戶用于遠(yuǎn)程登錄

# 創(chuàng)建用戶,10.0.0.0/24代表網(wǎng)段,只有在這個網(wǎng)段之內(nèi)的IP才能連接數(shù)據(jù)庫,密碼設(shè)置為huangsir
mysql> CREATE USER 'root'@'10.0.0.0/24' IDENTIFIED BY 'huangsir';
Query OK, 0 rows affected (0.01 sec)
# 授權(quán),*.*代表所有的庫和表
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.0.0.0/24' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
# 刷新權(quán)限
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

使用navicat連接數(shù)據(jù)庫測試

到此這篇關(guān)于Linux系統(tǒng)搭建單機MySQL8.0.26版本的文章就介紹到這了,更多相關(guān)linux mysql8.0搭建內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • MySQL中Distinct和Group By語句的基本使用教程

    MySQL中Distinct和Group By語句的基本使用教程

    這篇文章主要介紹了MySQL中Distinct和Group By語句的基本使用教程,這里主要是針對查詢結(jié)果去重的用法,需要的朋友可以參考下
    2015-12-12
  • 基于ubuntu中使用mysql實現(xiàn)opensips用戶認(rèn)證的解決方法

    基于ubuntu中使用mysql實現(xiàn)opensips用戶認(rèn)證的解決方法

    本篇文章小編為大家介紹,基于ubuntu中使用mysql實現(xiàn)opensips用戶認(rèn)證的解決方法。需要的朋友參考下
    2013-04-04
  • MySQL中文拼音排序的問題與解決方案

    MySQL中文拼音排序的問題與解決方案

    這篇文章主要為大家詳細(xì)介紹了MySQL中文拼音排序的問題和相關(guān)解決方案,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-09-09
  • mysql中插入emoji表情失敗的原因與解決

    mysql中插入emoji表情失敗的原因與解決

    這篇文章主要給大家介紹了關(guān)于mysql中插入emoji表情失敗的原因與解決方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • 基于mysql樂觀鎖實現(xiàn)秒殺的示例代碼

    基于mysql樂觀鎖實現(xiàn)秒殺的示例代碼

    本文主要介紹了基于mysql樂觀鎖實現(xiàn)秒殺,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • MySQL數(shù)據(jù)庫遷移全過程

    MySQL數(shù)據(jù)庫遷移全過程

    本文詳細(xì)解析了MySQL數(shù)據(jù)庫遷移的整個過程,包括準(zhǔn)備工作、遷移方法、注意事項和優(yōu)缺點,文章介紹了三種常見的遷移方法:使用mysqldump導(dǎo)出和導(dǎo)入、使用ibd文件遷移和使用目錄整體遷移,每種方法都有其優(yōu)缺點,選擇合適的方法取決于具體的遷移需求和環(huán)境
    2025-02-02
  • mysql 某字段插入隨機數(shù)(插入隨機數(shù)到MySQL數(shù)據(jù)庫)

    mysql 某字段插入隨機數(shù)(插入隨機數(shù)到MySQL數(shù)據(jù)庫)

    這篇文章主要介紹了mysql 某字段插入隨機數(shù)(插入隨機數(shù)到MySQL數(shù)據(jù)庫),需要的朋友可以參考下
    2016-09-09
  • 登錄MySQL數(shù)據(jù)庫最快幾步(圖文步驟詳解)

    登錄MySQL數(shù)據(jù)庫最快幾步(圖文步驟詳解)

    當(dāng)?MySQL?服務(wù)開啟后,就可以通過客戶端來登錄?MySQL?數(shù)據(jù)庫了。在?Windows?操作系統(tǒng)下可以使用?DOS?命令登錄數(shù)據(jù)庫,本節(jié)將介紹使用命令方式登錄?MySQL?數(shù)據(jù)庫的方法
    2023-10-10
  • MySQL優(yōu)化GROUP BY方案

    MySQL優(yōu)化GROUP BY方案

    滿足GROUP BY子句的最一般的方法是掃描整個表并創(chuàng)建一個新的臨時表,表中每個組的所有行應(yīng)為連續(xù)的,然后使用該臨時表來找到組并應(yīng)用累積函數(shù)(如果有)。在某些情況中,MySQL能夠做得更好,即通過索引訪問而不用創(chuàng)建臨時表。
    2014-07-07
  • 淺談mysql 自定義函數(shù)

    淺談mysql 自定義函數(shù)

    本文主要是分析了一下在工作中寫的一個mysql的自定義函數(shù),很簡單,僅僅是希望能對大家理解mysql自定義函數(shù)有所幫助。
    2014-09-09

最新評論

荣成市| 乐至县| 山东省| 曲水县| 辽阳县| 武乡县| 麟游县| 芦溪县| 溧水县| 满洲里市| 南漳县| 唐河县| 全南县| 湟源县| 东乡县| 大化| 绵竹市| 七台河市| 连平县| 瑞安市| 嘉禾县| 安义县| 邢台县| 莆田市| 会同县| 闵行区| 绿春县| 同仁县| 新乡县| 英德市| 保德县| 辛集市| 尉犁县| 贵定县| 鸡泽县| 镶黄旗| 乐都县| 崇州市| 乌什县| 揭西县| 海宁市|