2013-08-31 68 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)