匯入資料庫指令整理
終端機輸入
mysql -u 資料庫帳號 -p
>資料庫密碼
>use 資料庫名稱
>set global net_buffer_length=1000000;
>set global max_allowed_packet=1000000000;
>source 欲匯入的資料庫檔案(.sql檔)
mysql -u 資料庫帳號 -p
>資料庫密碼
>use 資料庫名稱
>set global net_buffer_length=1000000;
>set global max_allowed_packet=1000000000;
>source 欲匯入的資料庫檔案(.sql檔)
2025/8/19 更新
PostgreSQL17版本的匯出匯出
# Mac本地安裝pg17主控
brew install postgresql@17
# 直接呼叫pg_dump導出外部資料庫為自訂格式
/opt/homebrew/opt/postgresql@17/bin/pg_dump -Fc -v -d "postgresql://使用者A:使用者A密碼@目標主機A/資料庫A名稱?sslmode=require" -f dump.bak
# 透過pg_restore匯入到另一台db
/opt/homebrew/opt/postgresql@17/bin/pg_restore --no-owner --no-privileges -c -d "postgresql://使用者B:使用者B密碼@目標主機B/資料庫B名稱?sslmode=require" dump.bak
留言
張貼留言