Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 214
ObiHill Avatar asked Mar 14 '12 00:03

ObiHill


People also ask

How do I go back to MySQL in CMD?

also one other thing to note, if you realize you have made an error in your query and you want to go back and fix something enter \c at the prompt and then you will end your query and just go back to the prompt.

How do I end a MySQL session?

You can also terminate the session by issuing an EXIT statement or (under Unix) by typing Ctrl-D. The way you specify connection parameters for mysql also applies to other MySQL programs such as mysqldump and mysqladmin.

How do I get out of SQL command line?

To exit from mysql type quit at the mysql> command-prompt.

How do I exit MySQL workbench?

To quit MySQL Workbench select options File->Exit in a manu at the topmost line of MySQL Workbench window.


1 Answers

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.)

like image 78
sarnold Avatar answered Oct 21 '22 17:10

sarnold