ubuntu下,mysql預設資料庫存放路徑

2021-08-31 20:10:05 字數 823 閱讀 7148

ubuntu下,mysql預設資料庫存放路徑是 /var/lib/mysq。

一直以來都由著它預設沒管,可近來發現 /var 的空間不足了,而資料庫是一直增長的,只好考慮轉移一下。

於是移動了資料檔案,修改了許可權,修改了my.cnf,然後嘗試啟動,卻發現無法啟動起來。

檢視錯誤日誌檔案,發現好像是許可權的問題:

[note] plugin 'federated' is disabled.

/usr/sbin/mysqld: can't find file: './mysql/plugin.frm' (errno: 13)

[error] can't open the mysql.plugin table. please run mysql_upgrade to create it.

[error] /usr/sbin/mysqld: can't create/write to file '/data/mysql/zhetenga.com.pid' (errcode: 13)

[error] can't start server: can't create pid file: permission denied

於是我再檢查了許可權,發現許可權不應該有任何問題的,但仍然無法啟動,好奇怪。

最後通過以下修改終於讓mysql啟動成功了。

把/var/lib/mysql r,

/var/lib/mysql/** rwk,

中的 /var/lib/mysql 修改為新的路徑。

一直以來用 centos 也出現過類似的錯誤,都是目錄或檔案的許可權問題,而ubuntu除了目錄和檔案許可權外,還有這個配置檔案要改。

真折騰!

Ubuntu 16 04下修改MySQL預設編碼

本人多次嘗試,最終整理,伺服器為阿里雲ubunbtu16.04,操作成功 首先進入mysql存放配置檔案的目錄 cd etc mysql ls會發現有個檔案是my.cnf,這個檔案是mysql的配置檔案 用vim開啟此檔案 vim my.cnf開啟my.cnf後,會發現在此檔案的最後有兩行 此配置檔...

ubuntu下更改mysql預設編碼 字符集

sudo apt get install mysql server 直接自動獲得可用版本 也可以這樣寫 sudo apt get install mysql server 5.0 安裝mysql伺服器5.0版本 安裝後 etc init.d mysql start stop 為啟動和停止服務 ser...

Ubuntu10 04下C連線mysql資料庫

include include int main printf 釋放結果集的空間.n mysql free result res mysql close mysql 釋放資料庫 printf sql errror s n mysql error mysql 如果發生錯誤列印錯誤 return 0 編...