MySQL – Funda’s

Posted: April 11, 2012 in MySQL

  1. Show databases

a)      It shows all the databases in the server.

mysql> show databases;

+——————–+

| Database           |

+——————–+

| information_schema |

| cismysqldb         |

| mysql              |

| test               |

+——————–+

4 rows in set (0.02 sec)

2) Use Database

a)      We can use one of the database

mysql> use mysql;

Database changed

3) how to create user?

a)  create user sanjana identified by sanjana;

4) how to grant the permission to user?

a) grant dba to sanjana;

5) how to connect to the particular user?

a) 1.conn gopi/gopi@orcl;

2.conn sanjana/sanjana@orcl;

6) how to see the existing tables?

a) select * from tab;

7)      Select  host, user from user;

a)      We can get hosts and users granted permission by us.

 

mysql> select host, user from user;

+————–+——+

| host         | user |

+————–+——+

| 192.168.1.27 | root |

| 192.168.1.30 | root |

| 192.168.1.9  | root |

| localhost    | root |

+————–+——+

4         rows in set (0.01 sec)

 

8)      Granted Permission to a particular IP Address from Server?

a)      We can grant the permission to a particular IP Address using the below command.

 

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’192.168.1.29’ IDENTIFIED BY ‘PASSWORD’

WITH GRANT OPTION;

Query OK, 0 rows affected (0.00 sec)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s