MySQL on Windows 8 – Shutdown Issues

MySQLshutdownwindowswindows 8

Folks,

I am running MySQL on Windows8 for my personal (casual) use. I am trying to determine if there is a way to automatically and cleanly shutdown MySQL whenever I shutdown my Windows8 computer. Ideally, Windows is supposed to automatically stop the MySQL service as part of OS shutdown sequence. But I am not sure if it actually happens though. Any thoughts/ideas/recommendations around this subject will be appreciated!

Additional Information: Currently I am using a .bat script to do a "net stop" on the mysql Windows service. I manually invoke this .bat script just before I shutdown my computer.

Thank You.

Best Answer

If you would like to manually control this, here are some suggestions

Login to Window Command Line Shell as Administrator and run this

C:\> net stop mysql

When the prompt comes back, MySQL is down.

If you shutdown Windows, the only evidence for MySQL's shutdown would be in the error log.

EXAMPLE

On my laptop

  • I have MySQL 5.5.37 for Windows
  • It's been up since Dec 17, 2014
  • The error log filename says 12/17/2014 11:09 AM 83,010 ROLAED3573-NYTD.err
  • I just ran net stop mysql
  • The error log filename says 01/09/2015 02:02 PM 83,304 ROLAED3573-NYTD.err

From my actions, MySQL shutdown wrote 294 bytes at the end of the error log. What did it write ?

150109 14:02:33 [Note] MySQL: Normal shutdown

150109 14:02:33 [Note] Event Scheduler: Purging the queue. 0 events
150109 14:02:33  InnoDB: Starting shutdown...
150109 14:02:34  InnoDB: Shutdown completed; log sequence number 10001663889
150109 14:02:34 [Note] MySQL: Shutdown complete

Given this output, I would expect a shutdown to have these lines at the end of the error log.

UPDATE 2015-01-09 14:47 EST

I just ran this

C:\MySQL_5.5.37\data>net start mysql
The MySQL service is starting.
The MySQL service was started successfully.


C:\MySQL_5.5.37\data>

The error log says 01/09/2015 02:34 PM 84,289 ROLAED3573-NYTD.err

This landed at the bottom of the file

150109 14:34:48 [Note] Plugin 'FEDERATED' is disabled.
150109 14:34:48 InnoDB: The InnoDB memory heap is disabled
150109 14:34:48 InnoDB: Mutexes and rw_locks use Windows interlocked functions
150109 14:34:48 InnoDB: Compressed tables use zlib 1.2.3
150109 14:34:48 InnoDB: Initializing buffer pool, size = 1.0G
150109 14:34:48 InnoDB: Completed initialization of buffer pool
150109 14:34:48 InnoDB: highest supported file format is Barracuda.
150109 14:34:48  InnoDB: Waiting for the background threads to start
150109 14:34:49 InnoDB: 5.5.37 started; log sequence number 10001663889
150109 14:34:49 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
150109 14:34:49 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
150109 14:34:49 [Note] Server socket created on IP: '0.0.0.0'.
150109 14:34:50 [Note] Event Scheduler: Loaded 0 events
150109 14:34:50 [Note] MySQL: ready for connections.
Version: '5.5.37-log'  socket: ''  port: 3306  MySQL Community Server (GPL)

I have shutdown my laptop

I booted up my laptop

The error log says 01/09/2015 02:40 PM 85,568 ROLAED3573-NYTD.err

What did it write this time ?

150109 14:39:13 [Note] MySQL: Normal shutdown

150109 14:39:13 [Note] Event Scheduler: Purging the queue. 0 events
150109 14:39:13  InnoDB: Starting shutdown...
150109 14:39:13  InnoDB: Shutdown completed; log sequence number 10001663889
150109 14:39:13 [Note] MySQL: Shutdown complete

150109 14:40:04 [Note] Plugin 'FEDERATED' is disabled.
150109 14:40:04 InnoDB: The InnoDB memory heap is disabled
150109 14:40:04 InnoDB: Mutexes and rw_locks use Windows interlocked functions
150109 14:40:04 InnoDB: Compressed tables use zlib 1.2.3
150109 14:40:04 InnoDB: Initializing buffer pool, size = 1.0G
150109 14:40:04 InnoDB: Completed initialization of buffer pool
150109 14:40:04 InnoDB: highest supported file format is Barracuda.
150109 14:40:05  InnoDB: Waiting for the background threads to start
150109 14:40:06 InnoDB: 5.5.37 started; log sequence number 10001663889
150109 14:40:06 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
150109 14:40:06 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
150109 14:40:06 [Note] Server socket created on IP: '0.0.0.0'.
150109 14:40:06 [Note] Event Scheduler: Loaded 0 events
150109 14:40:06 [Note] MySQL: ready for connections.
Version: '5.5.37-log'  socket: ''  port: 3306  MySQL Community Server (GPL)

As shown from the end of the error log, it performed a clean shutdown at 2:39 PM. MySQL came back up when Windows was started.