If I run mysqld, ie invoke it directly on the command-line, it survives the shell being closed or hitting ctrl-c.

Is there any way to run it "interactively", ie so that it will shut down if either of those things happen?

(I'd find this useful during development as I have a tmux script to quickly bring up and down various servers.)

  • If you have a tmux script i'm sure you have enough shell ability to record the PID in a shell variable or temporary file, also whack your shell PID in a temporary file, fork off another shell script that sits there and checks if everything you've written to your temporary files is still running, and if not. kill -9. Done. Why would mysqlDAEMON be interactive?
    – Philᵀᴹ
    Nov 9, 2013 at 2:22
  • Like I said, it's a convenience thing for development. Almost all other Unix servers work this way, so it helps if everything is consisten without having to stop and think how each particular server in my workflow is bounced. And yes, I (and anyone else facing this issue) could jump through hoops writing and debugging PID-munging bash scripts, but I asked the question in case there's already a tool out there or some option I missed.
    – mahemoff
    Nov 9, 2013 at 11:04
  • Also, if I close the tmux session, all servers should go away (convenient for freeing up resources on a machine that's used for different purposes). Right now, one of those services sticks around.
    – mahemoff
    Nov 9, 2013 at 11:30

2 Answers 2


You could try --gdb. That will make it respond to SIGINT, though I'm not sure if that has potential to corrupt the database. --one-thread may also be of some help.

  • I've been trying --gdb for a while now and it's worked great, thanks.
    – mahemoff
    Dec 3, 2013 at 12:25

If installing the initscript and using the standard sudo service mysql start | stop aren't on the list of things you consider reasonable options, you could always compile your own version of mysqld with some custom hackery to the signal handling code in sql/mysqld.cc where it looks like some signals aren't defined yet, so presumably no-ops just waiting for some copy/paste, though there may be additional code that is masking them before this switch is hit.

switch (sig) {
      sql_print_information("Got signal %d to shutdown mysqld",sig);
      /* switch to the old log message processing */
      logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
                          opt_log ? LOG_FILE:LOG_NONE);
      DBUG_PRINT("info",("Got signal: %d  abort_loop: %d",sig,abort_loop));
      if (!abort_loop)
        abort_loop=1;       // mark abort for threads
        /* Delete the instrumentation for the signal thread */
        pthread_t tmp;
        if (mysql_thread_create(0, /* Not instrumented */
                                &tmp, &connection_attrib, kill_server_thread,
                                (void*) &sig))
          sql_print_error("Can't create thread to kill server");
        kill_server((void*) sig); // MIT THREAD has a alarm thread

Otherwise, no.

  • 1
    This makes sense... if you want to recompile the source you should add SIGINT (triggerd by ctrl-c) to that switch case and call the function kill_server that would do the trick.. Nov 9, 2013 at 16:56

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.