| 參數 | 效果 |
|---|---|
-f / --force | 遇到 SQL 錯誤**記錄並繼續**,不終止匯入流程 |
--show-warnings | 顯示 Warning 詳細資訊 |
-v / --verbose | 顯示出錯的具體資料行(配合 tee 記錄完整日誌) |
# 匯入大量 SQL 檔,錯誤不中斷、顯示警告、詳細日誌
mysql -u root -p -f --show-warnings -v target_db < dump.sql 2>&1 | tee import.log
tee import.log 將終端輸出同步寫入檔案。grep -n "ERROR\|Warning" import.log 快速定位問題行。--show-warnings 獲取 MySQL 回傳的詳細錯誤代碼與訊息。