2013-08-31 121 views
0

我想從命令行關閉mysql服務器。從命令行關閉mysql [Windows] [DOS]

如果我使用taskkill.exe或強制,它會停止mysql服務器,但是當我再次啓動mysql時。它顯示

2013-08-31 16:00:35 3940 [Note] InnoDB: Database was not shutdown normally! 
2013-08-31 16:00:35 3940 [Note] InnoDB: Starting crash recovery. 
2013-08-31 16:00:35 3940 [Note] InnoDB: Reading tablespace information from the .ibd files... 
2013-08-31 16:00:35 3940 [Note] InnoDB: Restoring possible half-written data pages 
2013-08-31 16:00:35 3940 [Note] InnoDB: from the doublewrite buffer... 
2013-08-31 16:00:35 3940 [Note] InnoDB: 128 rollback segment(s) are active. 
2013-08-31 16:00:35 3940 [Note] InnoDB: Waiting for purge to start 
2013-08-31 16:00:35 3940 [Note] InnoDB: 5.6.13 started; log sequence number 1600927 
2013-08-31 16:00:35 3940 [Note] Recovering after a crash using mysql-bin 
2013-08-31 16:00:35 3940 [Note] Starting crash recovery... 
2013-08-31 16:00:35 3940 [Note] Crash recovery finished. 

恢復實際上需要時間來啓動服務器。如果數據庫非常大,它有時也會啓動失敗。

所以,我要關機一般都喜歡:

mysqladmin -u root -pmysql shutdown

上述命令的作品,但MySQL root密碼可能會改變,所以我想的Mac OS X的下的類似命令的Windows

mysqladmin -u root -p$(cat /path/to/mysql/root/password) shutdown 

基本上我想從文件中讀取密碼。在DOS中可以嗎?

任何幫助?謝謝。

回答

0

已解決。

這裏是命令

for /f "tokens=*" %f in ('type path\to\mysql\root\password.txt') do @(mysqladmin -u root -p%f shutdown)