mysql 匯出 匯入

來源:互聯網
上載者:User

標籤:mysqld   思路   tab   nbsp   drop   匯入表   roo   tables   win   

一、匯出

  windows下 切換到mysql安裝目錄bin目錄下

  匯出 資料庫lz_garden 下的 所有表結構 到d盤並命名為lz_garden.sql:  

D:\dev\MySQL\MySQL Server 5.5\bin>mysqldump -u root -p -d --add-drop-table lz_garden > d:/lz_garden.sql

    匯出 資料庫lz_garden 下的 所有 到d盤並命名為lz_garden.sql:

D:\dev\MySQL\MySQL Server 5.5\bin>mysqldump -u root -p lz_garden > d:/lz_garden.sql

   

二、匯入mysql檔案

   進入mysql, use 當前資料庫,然後使用source 命令,如下:

mysql> source d:/lz_garden.sql;

 

 三、mysql 匯入表結構後主鍵自增id不是從1開始,基本思路是 truncate 資料庫下 所有表。

     使用以下命令,匯入到d盤為truncate.sql檔案:   

mysql> select Concat(‘TRUNCATE TABLE ‘, TABLE_NAME, ‘;‘) from INFORMATION_SCHEMA.TABLES  WHERE TABLE_SCHEMA = ‘lz_garden2‘ into outfile ‘d:/truncate.sql‘;

開啟該檔案,全部複製,執行便可。

 

mysql 匯出 匯入

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.