Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Win7 CMD 命令行匯出 MySQL 表資料實戰

編輯:Win7 系統應用技巧

使用 mysqldump 工具可快速匯出單表資料至文字檔,適合備份、遷移、分析。

前置條件

  • MySQL 已安裝且服務運行中。
  • 環境變數 Path 包含 MySQL bin 目錄(如 C:\Program Files\MySQL\MySQL Server 5.7\bin),否則需完整路徑執行。

匯出指令範例

# 基本語法
mysqldump -h [主機] -u [使用者] -p [資料庫] [資料表] > [輸出檔路徑]

# 實際範例:匯出 tomtopportal 資料庫的 t_article_base 表到 E 盤
mysqldump -h localhost -u root -p tomtopportal t_article_base > E:\xitongcheng.com.txt

操作步驟

  1. Win+R → cmd → 以系統管理員身分執行。
  2. 貼上上述指令按 Enter。
  3. 提示 Enter password: 輸入 MySQL root 密碼(輸入過程不顯示字元),按 Enter。
  4. 游標閃爍結束、無錯誤訊息即代表成功,前往 E:\xitongcheng.com.txt 驗證。

常用參數擴充

參數用途
--single-transactionInnoDB 熱備份不鎖表
--where="id > 1000"條件篩選匯出
--no-data僅匯出結構
-B db1 db2匯出多個資料庫
Copyright © Windows教程網 All Rights Reserved