1

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.

2
  • I just added my answer and then you said you are doing that already. Commented Jan 9, 2015 at 17:54
  • Yeah, it seems we were just a few seconds apart at that. Any other ideas to avoid this manual shell script?
    – user309223
    Commented Jan 9, 2015 at 18:54

1 Answer 1

2

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.

6
  • Thank you for the explanation. Is it possible for you to try this once again but this time do not run "net stop mysql". Instead, just shut Windows down and then look at the error log. I'd like to see if Windows internally does a "net stop mysql" as part of shutdown sequence.
    – user309223
    Commented Jan 9, 2015 at 19:27
  • I'll start MySQL, reboot my laptop, BRB ... Commented Jan 9, 2015 at 19:29
  • I have updated my answer with my findings Commented Jan 9, 2015 at 19:47
  • 1
    Awesome. So it looks like Windows is cleanly shutting down MySQL afterall. Cannot wait to try this when I reach home :) Thanks a lot for you help!! I will report back my experience on Monday next week.
    – user309223
    Commented Jan 9, 2015 at 21:14
  • 1
    I can confirm that Windows8 correctly shuts down MySQL automatically and cleanly. Just like Rolando, I can see following in my log file: - 2015-01-11 15:57:58 6448 [Note] C:/Program Files/MySQL/MySQL Server 5.6/bin\mysqld: Shutdown complete
    – user309223
    Commented Jan 11, 2015 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.