MySQL – How to Put Database into Maintenance Mode

maintenanceMySQL

I'm going to be doing some complicated maintenance on our MySQL servers and I'd like to keep users out during the work. I'd prefer not to drop and re-create all of the user accounts, but that's the only solution I've come up with so far. Hmm.. Refusing network connections would work as well, as the maintenance will be done via an os-local mysql CLI. I'd prefer to not have to stop and re-start the server, but that's not impossible.

What are best practices here?

Thanks in advance,
Brad

Best Answer

Issue the command:

service mysql restart --skip-networking

This prevents all TCP/IP connections.

You can login as root@localhost and the client program will use the socket file rather than TCP/IP. Do all your DDL work. Can you shut down the web-server (if you're using one)?