Quickly shutdown MariaDB 10

Italian version

How do you normally shutdown a MariaDB 5.5 or MySQL server?

mysqladmin shutdown -uroot -p

But MariaDB 10 (beta quality, at the time of this writing) has a quick way to do the same:

C:\Documents and Settings\utente1>mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.0.4-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT 'I\'m alive!';
| I'm alive! |
| I'm alive! |
1 row in set (0.00 sec)

MariaDB [(none)]> SHUTDOWN;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SELECT 'I\'m gone away';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061 "Unknown
ERROR: Can't connect to the server

unknown [(none)]> \q

Update: SHUTDOWN works in stored programs. This allows to write an event which turns the server off everyday at a certain time, or when a task is finished. This is safer than a cron job which kills it, and works on any system.

CREATE EVENT `test`.`shutd`
        EVERY 1 DAY
        STARTS '2014-01-01 20:00:00'
    COMMENT 'Shutdown Maria when the office closes'


2 thoughts on “Quickly shutdown MariaDB 10

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s