Friday, 1 February 2013

Current Working DATABASE!


To konw current working database in mysql:

 

Generally, The mysql Working environment like below,

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ranjith_test       |
| test               |
+--------------------+
4 rows in set (0.14 sec)

mysql> use ranjith_test;
Database changed
mysql>

Add the following sector in my.cnf file to konw current working DB name

[mysql]

prompt=`mysql(\d)>`


Then restart the mysql service.

[root@ranjith ~]# /etc/init.d/mysqld restart
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]
[root@ranjith ~]#

Here, the mysql(\d) within symbol "`" is nothing but a back-ticket.


After adding the above sector in my.cnf file, Yoru mysql environment start showing the current database name which you are working with,

`mysql((none))>`show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ranjith_test       |
| test               |
+--------------------+
4 rows in set (0.01 sec)

`mysql((none))>`use ranjith_test;
Database changed
`mysql(ranjith_test)>`
`mysql(ranjith_test)>`
`mysql(ranjith_test)>`use test;
Database changed
`mysql(test)>`
`mysql(test)>`
`mysql(test)>`exit
Bye


No comments:

Post a Comment