ObiHill
ObiHill

Reputation: 11876

Terminating MySQLd session to go back to command prompt

I'm using Ubuntu Natty.

I ran mysqld from the command line using the following:

mysqld -ndbcluster --console -umysql

To which I get the following:

120314  0:09:49 [Warning] option 'new': boolean value 'dbcluster' wasn't recognized. Set to OFF.
120314  0:09:49 [Note] Plugin 'ndbcluster' is disabled.
120314  0:09:49 [Note] Plugin 'FEDERATED' is disabled.
120314  0:09:50 InnoDB: The InnoDB memory heap is disabled
120314  0:09:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120314  0:09:50 InnoDB: Compressed tables use zlib 1.2.3
120314  0:09:50 InnoDB: Using Linux native AIO
120314  0:09:50 InnoDB: Initializing buffer pool, size = 128.0M
120314  0:09:50 InnoDB: Completed initialization of buffer pool
120314  0:09:50 InnoDB: highest supported file format is Barracuda.
120314  0:09:50  InnoDB: Waiting for the background threads to start
120314  0:09:51 InnoDB: 1.1.8 started; log sequence number 1595675
120314  0:09:51 [Note] Event Scheduler: Loaded 0 events
120314  0:09:51 [Note] mysqld: ready for connections.
Version: '5.5.19-ndb-7.2.4-gpl-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Cluster Community Server (GPL)

However, I can't seem to figure out how to terminate the session. I've tried Control-C and a host of other combinations.

How do I end the session and go back to the command prompt?!

Thanks.

Upvotes: 4

Views: 2977

Answers (2)

sarnold
sarnold

Reputation: 104080

ctrl+c will generate SIGINT, which can be caught or blocked by the application. If you just run killall mysqld from another terminal, you'll send SIGTERM to the process, which can also be caught or blocked, but will give a much stronger hint that the process should terminate immediately. (Which will be nice for cleanly closing database tables.)

Ctrl+</kbd> will generate SIGQUIT, which can be caught or blocked by the application. (If the application doesn't catch or block this signal, the OS will generate a core file for you.)

You can send a SIGKILL by hand using kill(1); SIGKILL cannot be caught or blocked, and thus will always terminate a process if the kernel is alive enough to process the signal. Find the pid using pidof or another mechanism, and run kill -SIGKILL pid. Note that this is a rough death; the process is not given a chance to clean up after itself, so database tables may be left in an inconsistent state that may require some time to repair on the next start.

If you just want a prompt back, you can use ctrl+z to suspend the process. You can then use your shell's bg and fg commands to allow the process to continue running in the background, or re-join the process in the foreground. (That terminology is non-sense, but I hope it conveys the idea.)

Upvotes: 12

Vladimir Panteleev
Vladimir Panteleev

Reputation: 25187

Press Ctrl+\.

MySQL seems to ignore SIGINT (which is emitted when pressing Ctrl+C), but will perform a clean shutdown when it receives SIGQUIT (which is what Ctrl+\ sends).

See samold's answer for details.

Upvotes: 3

Related Questions