溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么在Linux中修改MySQL數(shù)據(jù)庫數(shù)據(jù)文件路徑

發(fā)布時(shí)間:2021-05-26 10:59:14 來源:億速云 閱讀:262 作者:Leah 欄目:MySQL數(shù)據(jù)庫

今天就跟大家聊聊有關(guān)怎么在Linux中修改MySQL數(shù)據(jù)庫數(shù)據(jù)文件路徑,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

步驟:

1、創(chuàng)建目標(biāo)路徑

mkdir -p /home/mysql_data

2、關(guān)閉MySQL

systemctl stop mysqld

3、復(fù)制數(shù)據(jù)文件

cp -arp /var/lib/mysql /home/mysql_data

4、修改配置文件/etc/my.cnf

將datadir和socket中的原路徑修改為目標(biāo)路徑

datadir=/home/mysql_data/mysql
socket=/home/mysql_data/mysql/mysql.sock

5、啟動MySQL服務(wù)

systemctl start mysqld

NOTE:

1、報(bào)錯如下:

2019-12-22T08:32:42.430564Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2019-12-22T08:32:42.430599Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2019-12-22T08:32:42.430616Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-12-22T08:32:42.430898Z 0 [ERROR] InnoDB: The innodb_temporary data file 'ibtmp1' must be writable
2019-12-22T08:32:42.430923Z 0 [ERROR] InnoDB: The innodb_temporary data file 'ibtmp1' must be writable
2019-12-22T08:32:42.430936Z 0 [ERROR] InnoDB: Could not create the shared innodb_temporary.
2019-12-22T08:32:42.430952Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-12-22T08:32:43.038973Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2019-12-22T08:32:43.039021Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2019-12-22T08:32:43.039037Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-12-22T08:32:43.039046Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-12-22T08:32:43.039056Z 0 [ERROR] Failed to initialize builtin plugins.
2019-12-22T08:32:43.039063Z 0 [ERROR] Aborting

解決:

執(zhí)行命令:

setenforce 1

再重新啟動

2、報(bào)錯如下:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

解決:

修改配置文件my.cnf,添加或修改如下配置:

[client]
socket = /home/mysql_data/mysql/mysql.sock

看完上述內(nèi)容,你們對怎么在Linux中修改MySQL數(shù)據(jù)庫數(shù)據(jù)文件路徑有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI