匯入資料庫指令整理

終端機輸入

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

留言

這個網誌中的熱門文章

2022亞太電信魔術方塊一代申裝 2025遠傳低功率轉發器(強波器)申裝

開放麒麟系統openKylin1.0安裝

AI繪圖工具整理 Stable Diffusion、Easy Diffusion、Draw Things、BingCreate