修改MySQL8.0 默認(rèn)的數(shù)據(jù)目錄(快捷操作無配置)
使用場景:我們使用的是阿里云,單獨(dú)購買了數(shù)據(jù)盤(空間大并可做備份),MySQL 8.0 數(shù)據(jù)庫默認(rèn)裝在系統(tǒng)盤上,為了考慮安全性和空間問題,我們需要將默認(rèn)的數(shù)據(jù)庫目錄更改到其它位置(我這里是SSD數(shù)據(jù)盤,通過掛載)
操作系統(tǒng):CentOS 7.6 數(shù)據(jù)庫: MySQL 8.0 查看我本人更多原創(chuàng)文章,請(qǐng)點(diǎn)擊這里
MySQL 8.0 默認(rèn)數(shù)據(jù)目錄位置為:/var/lib/mysql
我的目標(biāo)位置為:/data/
現(xiàn)在我們開始操作吧
1、首先我們停止 MySQL 8.0 服務(wù),使用下面的指令
[root@JasonSong ~]# sudo systemctl stop mysqld.service
使用以下指令檢查服務(wù)是否已停止
[root@JasonSong ~]# sudo systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: inactive (dead) since Thu 2019-02-21 13:52:24 CST; 9s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 6152 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 6082 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 6152 (code=exited, status=0/SUCCESS) Status: "SERVER_SHUTTING_DOWN" Feb 20 16:30:39 JasonSong systemd[1]: Starting MySQL Server... Feb 20 16:30:50 JasonSong systemd[1]: Started MySQL Server. Feb 21 13:52:21 JasonSong systemd[1]: Stopping MySQL Server... Feb 21 13:52:24 JasonSong systemd[1]: Stopped MySQL Server.
2、將默認(rèn)的數(shù)據(jù)目錄移至目標(biāo)位置
[root@JasonSong ~]# mv /var/lib/mysql/ /data/
將在目標(biāo)位置軟鏈至原始位置,使用以下指令建立軟鏈接
[root@JasonSong ~]# ln -s /data/mysql /var/lib/
檢查是否已鏈接成功,使用以下指令
[root@JasonSong ~]# ls -la /var/lib/mysql lrwxrwxrwx 1 root root 11 Feb 21 14:00 /var/lib/mysql -> /data/mysql
顯示上面的信息后可以啟動(dòng) MySQL 服務(wù)進(jìn)行測試一下哦
[root@JasonSong ~]# sudo systemctl start mysqld.service [root@JasonSong ~]# sudo systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2019-02-21 14:02:13 CST; 8s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 21361 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 21379 (mysqld) Status: "SERVER_OPERATING" CGroup: /system.slice/mysqld.service └─21379 /usr/sbin/mysqld Feb 21 14:02:12 JasonSong systemd[1]: Starting MySQL Server... Feb 21 14:02:13 JasonSong systemd[1]: Started MySQL Server.
顯示上面的信息表示OK啦,查看我本人更多原創(chuàng)文章,請(qǐng)點(diǎn)擊這里。
到此這篇關(guān)于修改MySQL8.0 默認(rèn)的數(shù)據(jù)目錄(快捷操作無配置)的文章就介紹到這了,更多相關(guān)修改MySQL默認(rèn)目錄內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Linux系統(tǒng)中安裝MySQL的詳細(xì)圖文步驟
本文的主要內(nèi)容是在 Linux 上安裝 MySQL,以下內(nèi)容是源于 B站 - MySQL數(shù)據(jù)庫入門到精通 整理而來,需要的朋友可以參考下2023-06-06MySQL show process命令監(jiān)控診斷數(shù)據(jù)庫性能詳解
這篇文章主要為大家介紹了MySQL show process命令監(jiān)控診斷數(shù)據(jù)庫性能詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-10-10MySQL實(shí)現(xiàn)數(shù)據(jù)更新的示例詳解
這篇文章主要為大家詳細(xì)介紹了MySQL實(shí)現(xiàn)數(shù)據(jù)更新的相關(guān)資料,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-02-02MySQL中數(shù)據(jù)類型相關(guān)的優(yōu)化辦法
這篇文章主要介紹了MySQL中數(shù)據(jù)類型相關(guān)的優(yōu)化辦法,包括使用多列索引等相關(guān)的優(yōu)化方法,需要的朋友可以參考下2015-07-07Navicat中新建MySQL數(shù)據(jù)庫與新建、修改、刪除數(shù)據(jù)表及刪除數(shù)據(jù)庫詳細(xì)操作方法
Navicat是一套快速、可靠并價(jià)格相當(dāng)便宜的數(shù)據(jù)庫管理工具,專為簡化數(shù)據(jù)庫的管理及降低系統(tǒng)管理成本而設(shè),這篇文章主要給大家介紹了關(guān)于Navicat中新建MySQL數(shù)據(jù)庫與新建、修改、刪除數(shù)據(jù)表及刪除數(shù)據(jù)庫詳細(xì)操作的相關(guān)資料,需要的朋友可以參考下2023-11-11mysql啟動(dòng)提示mysql.host 不存在,啟動(dòng)失敗的解決方法
我將s9當(dāng)眾原來的mysql4.0刪除后,重新裝了個(gè)mysql5.0,啟動(dòng)過程中報(bào)一下錯(cuò)誤,啟動(dòng)失敗,查了一下群里面的老帖子也沒有個(gè)具體的明確說明2011-10-10解決出現(xiàn)secure_file_priv null的問題
這篇文章主要介紹了解決出現(xiàn)secure_file_priv null的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-03-03