Is there any way to graceful restart mysqld?
Exact duplicate?

Is there a graceful or safe restart for mysql like for apache httpd?

Basically, it involves some SQL scripting along with whatever operating system scripts or controls you are using to do the server restart.
Just be mindful of how the locking interacts with transactions: http://dev.mysql.com/doc/refman/5.6/en/lock-tables-and-transactions.html