从命令行关闭mysql [Windows] [DOS]

时间:2013-08-31 10:58:53

标签: mysql windows macos dos mysqladmin

我想从命令行关闭mysql服务器。

如果我使用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密码可能会更改所以我想要 Windows 下面的类似Mac OS X 命令:

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

基本上我想从文件中读取密码。在DOS中有可能吗?

有任何帮助吗?感谢。

1 个答案:

答案 0 :(得分:0)

解决。

这是命令

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