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

吉加尔

我想从命令行关闭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根密码可能会更改,因此我想Windows使用类似Mac OS X的命令

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

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

有什么帮助吗?谢谢。

吉加尔

解决了。

这是命令

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章