搜尋
首頁資料庫mysql教程Centos7.9安裝MySQL8.0.32的方法是什麼

Centos7.9安裝MySQL8.0.32的方法是什麼

May 30, 2023 pm 01:46 PM
mysqlcentos

第一步、下載壓縮套件

下載社群版的 MySQL,根據需求下載對應版本,其中有最小安裝版本。

Centos7.9安裝MySQL8.0.32的方法是什麼

第二步,解壓縮壓縮包,並複製到安裝目錄

#進入到壓縮包所在的資料夾,解壓縮分成兩次,第一次解壓縮xz 文件,第二次解壓縮tar 文件。

xz -dv mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
tar -xvf mysql-8.0.32-linux-glibc2.12-x86_64.tar

複製解壓縮後的檔案到要安裝的目錄,我要把MySQL 安裝到/usr/local/mysql,所以,執行以下指令,把解壓縮後的檔案複製過去

sudo cp -r mysql-8.0.32-linux-glibc2.12-x86_64/* /usr/local/mysql

這裡需要修改以下安裝目錄的權限,由於我們使用mysql 用戶運行資料庫,所以,要把安裝目錄的擁有者改為mysql,如果系統沒有,需要添加mysql 用戶及分組,我們只使用mysql 運行程序,所以指定了mysql 禁止登錄,增加安全性

sudo groupadd mysql
sudo useradd mysql -s /usr/sbin/nologin -g mysql

修改安裝目錄的擁有者為mysql

chown -R mysql:mysql /usr/local/mysql/

第三步、編輯設定檔

編輯設定文件,我們把設定檔放到/etc/my.cnf

設定如下:

[client]
port=3306
# 端口
# mysqlx_port=33060
socket=/var/lib/mysql/mysql.sock
# mysqlx_socket=/var/lib/mysqlx.sock

[mysqld]
# skip-grant-tables
# mysql安装目录
basedir=/usr/local/mysql/
# mysql数据库目录
datadir=/var/lib/mysql/data/
port=3306
innodb_file_per_table=1
character-set-server=UTF8MB4
mysqlx_port=33060
socket = /var/lib/mysql/mysql.sock
# mysqlx_socket=/var/lib/mysql/mysqlx.sock

[mysqld_safe]
# 错误日志
log-error=/var/log/mysql/error.log
# pid文件
pid-file=/usr/local/mysql/mysqld.pid
tmpdir=/var/lib/mysql/mysql

第四步、確定一些相關的目錄

編輯檔案support-files/mysql. server,修改裡面的相關目錄

安裝目錄basedir=/usr/local/mysql

設定目錄/etc/my.cnf

資料庫檔案目錄datadir=/var /lib/mysql/data/

pid 檔案pid-file=/usr/local/mysql/mysqld.pid

第五步、初始化資料庫

初始化資料庫,注意,初始化成功後,終端機會顯示root 帳號密碼,一定要儲存下來

sudo ./bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize

第六步、啟動資料庫,連線並修改root 密碼

sudo ./bin/mysqld --defaults-file=/etc/my.cnf --user=mysql

連線資料庫,修改root 密碼

ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';

第六步、守護MySQL 程序

建立守護程序,保證在伺服器重新啟動後能夠自動啟動,執行

sudo vim /etc/systemd/system/mysql.service

內容如下,其中User 和Group 為mysql

[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
#Restart=on-failure
#RestartPreventExitStatus=1
#PrivateTmp=false
# 使能
sudo systemctl enable mysql.service
# 启动
sudo systemctl start mysql.service
# 查看状态
sudo systemctl status mysql.service

第七步、驗證

重啟伺服器驗證mysql 程序是否啟動

以上是Centos7.9安裝MySQL8.0.32的方法是什麼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文轉載於:亿速云。如有侵權,請聯絡admin@php.cn刪除
如何在MySQL中刪除或修改現有視圖?如何在MySQL中刪除或修改現有視圖?May 16, 2025 am 12:11 AM

todropaviewInmySQL,使用“ dropviewifexistsview_name;” andTomodifyAview,使用“ createOrreplaceViewViewViewview_nameAsSelect ...”。 whendroppingaview,asew dectivectenciesanduse和showcreateateviewViewview_name;“ tounderStanditSsstructure.whenModifying

MySQL視圖:我可以使用哪些設計模式?MySQL視圖:我可以使用哪些設計模式?May 16, 2025 am 12:10 AM

mySqlViewScaneFectectialized unizedesignpatternslikeadapter,Decorator,Factory,andObserver.1)adapterPatternadaptSdataForomDifferentTablesIntoAunifiendView.2)decoratorPatternenhancateDataWithCalcalcualdCalcalculenfields.3)fieldfields.3)

在MySQL中使用視圖的優點是什麼?在MySQL中使用視圖的優點是什麼?May 16, 2025 am 12:09 AM

查看InMysqlareBeneForsImplifyingComplexqueries,增強安全性,確保dataConsistency,andOptimizingPerformance.1)他們simimplifycomplexqueriesbleiesbyEncapsbyEnculatingThemintoreusableviews.2)viewsEnenenhancesecuritybyControllityByControllingDataAcces.3)

如何在MySQL中創建一個簡單的視圖?如何在MySQL中創建一個簡單的視圖?May 16, 2025 am 12:08 AM

toCreateAsimpleViewInmySQL,USEthecReateaTeviewStatement.1)defitEtheetEtheTeViewWithCreatEaTeviewView_nameas.2)指定usethectstatementTorivedesireddata.3)usethectStatementTorivedesireddata.3)usetheviewlikeatlikeatlikeatlikeatlikeatlikeatable.views.viewssimplplifefifydataaccessandenenanceberity but consisterfort,butconserfort,consoncontorfinft

MySQL創建用戶語句:示例和常見錯誤MySQL創建用戶語句:示例和常見錯誤May 16, 2025 am 12:04 AM

1)foralocaluser:createUser'localuser'@'@'localhost'Indidendify'securepassword'; 2)foraremoteuser:creationuser's creationuser'Remoteer'Remoteer'Remoteer'Remoteer'Remoteer'Remoteer'Remoteer'Remoteer'Rocaluser'@'localhost'Indidendify'seceledify'Securepassword'; 2)

在MySQL中使用視圖的局限性是什麼?在MySQL中使用視圖的局限性是什麼?May 14, 2025 am 12:10 AM

mysqlviewshavelimitations:1)他們不使用Supportallsqloperations,限制DatamanipulationThroughViewSwithJoinsOrsubqueries.2)他們canimpactperformance,尤其是withcomplexcomplexclexeriesorlargedatasets.3)

確保您的MySQL數據庫:添加用戶並授予特權確保您的MySQL數據庫:添加用戶並授予特權May 14, 2025 am 12:09 AM

porthusermanagementinmysqliscialforenhancingsEcurityAndsingsmenting效率databaseoperation.1)usecReateusertoAddusers,指定connectionsourcewith@'localhost'or@'%'。

哪些因素會影響我可以在MySQL中使用的觸發器數量?哪些因素會影響我可以在MySQL中使用的觸發器數量?May 14, 2025 am 12:08 AM

mysqldoes notimposeahardlimitontriggers,butacticalfactorsdeterminetheireffactective:1)serverConfiguration impactactStriggerGermanagement; 2)複雜的TriggerSincreaseSySystemsystem load; 3)largertablesslowtriggerperfermance; 4)highConconcConcrencerCancancancancanceTigrignecentign; 5); 5)

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)