سؤال

I want to shutdown mysql server from command line.

If I use taskkill.exe or forcefully, it stops the mysql server but when I start mysql again. It shows

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.

Recovery actually takes time to start the server. And also sometimes it gets failed to start, if the database is extremely large.

So I want to shutdown normally like:

mysqladmin -u root -pmysql shutdown

Above command works but MySQL Root Password may change so I want a similar command of Mac OS X below for Windows:

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

Basically I want to read the password from file. Is it possible in DOS ?

Any help ? Thanks.

هل كانت مفيدة؟

المحلول

Solved.

Here is the command

for /f "tokens=*" %f in ('type path\to\mysql\root\password.txt') do @(mysqladmin -u root -p%f shutdown)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top