MySQL用批處理命令自動刪除重建資料庫實現壓縮ibdata1檔案容量

來源:互聯網
上載者:User

一、友情提醒,以下操作會刪除資料庫,請事先自行備份資料庫檔案

二、需要3個檔案,以下為3個檔案的檔案名稱及內容:

檔案1:Mysql_Drop_DataBase.txt,內容如下:

drop database yourdatabase;

檔案2:Mysql_Create_DataBase.txt,內容如下:

create database yourdatabase;

檔案3:自動壓縮ibdata1檔案容量.bat,內容如下:

rem 刪除資料庫
mysql -u 使用者名稱 --password=密碼 < "Mysql_Drop_DataBase.txt"

rem 停止mysql服務
net stop mysql

rem 刪除ibdata1、iblogfile0、ib_logfile1檔案,請自行替換以下檔案路徑
Del "G:\MySQL Datafiles\ibdata1"
Del "C:\ProgramData\MySQL\MySQL Server 5.5\data\ib_logfile0"
Del "C:\ProgramData\MySQL\MySQL Server 5.5\data\ib_logfile1"

rem 啟動mysql服務
net start mysql

rem 建立資料庫
mysql -u 使用者名稱 --password=使用者名稱 < "Mysql_Create_DataBase.txt"

三、點擊“自動壓縮ibdata1檔案容量.bat”開始運行

相關文章

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.