:::| 目前位置圖示目前位置:首頁圖示回首頁 | 主功能頁圖示相關問答
mariadb 資料庫目錄遷移至不同目錄

[日期]:2024/10/08  [瀏覽人數]:93

當資料庫太大,原本規劃的/var分割空間不足時,可以將資料目錄/var/db/mysql用ln連接至其他足以使用的分割區

#/usr/local/etc/rc.d/mysql-server stop

#cd /var/db

#cp -rp /var/db/mysql/* /storage/mysql/mysql

#mv mysql mysql.bak

#chown -R /storage/mysql/mysql mysql

#chgrp -R /storage/mysql/mysql mysql

#ln -s /storage/mysql/mysql /var/db/mysql

#/usr/local/etc/rc.d/mysql-server start

注意須要將要link的目錄的使用者及群組權限設定為mysql,否則將會造成mariadb因檔案權限不足而無法啟動。

如:在/var/log/mysql/mysqld.err的log在啟動失敗時出現如下LOG

2024-10-08 15:07:12 0 [Note] Starting MariaDB 10.6.19-MariaDB-log source revision 8f020508c87461bbeee551c3001acac56d506ae7 server_uid gimMfWVVx3tYdrFipkPFlgYUtk8= as process 33686
2024-10-08 15:07:12 0 [ERROR] mariadbd: File './mysql-bin.~rec~' not found (Errcode: 13 "Permission denied")
2024-10-08 15:07:12 0 [ERROR] MYSQL_BIN_LOG::open_purge_index_file failed to open register file.
2024-10-08 15:07:12 0 [ERROR] MYSQL_BIN_LOG::open_index_file failed to sync the index file.
2024-10-08 15:07:12 0 [ERROR] Aborting