HowTo : Execute BASH Shell Commands over MySQL environment in Linux?

Yes, We can execute shell commands over mysql environment without exit by adding "\! " before commands as like "\! command",

mysql> \! uptime
 06:52:18 up 36 min,  1 user,  load average: 0.00, 0.00, 0.00
mysql>

mysql> \! pwd
/root
mysql>

(or) We can get the shell prompt here by doing,

mysql> \! bash

(or)

mysql> \! sh


HowTo: Get current working database information in mysql?

Add the below lines in /etc/my.cnf

[mysql]
prompt=`mysql(\d)>`

your  mysql environment will be,


`mysql((none))>`


To revert this,

HowTo: Get hostname in mysql environment?

Add the below lines in /etc/my.cnf

[mysql]
prompt=`mysql(\h)>`

Also in /root/.my.cnf should have below,
[client]
host=valid.hostname.com
user="root"
pass="password"

please make sure the hostname should be valid and added in /etc/hosts


If you would like to return default PROMPT of mysql(this time only)

`mysql(ranjith.time.com)>`\R
Returning to default PROMPT of mysql>
mysql>

Enjoy !!....

Comments

Popular posts from this blog

Resolved: DOCKER: Error response from daemon: Could not attach to network / rpc error: code = 7 desc = network not manually attachable.

yum failed 6 times. Cannot continue!

unexpectedly shrunk window (repaired) in dmesg log - TCP Peer