1. HOW TO INSTALL MYSQL ON RHEL5
[root@training ~]# yum install mysql-server mysql[root@training ~]# service mysqld restart
[root@training ~]# chkconfig mysqld on
2. TO MAKE ADMIN USER IN MYSQL
[root@training ~]# mysqladmin -u root password PASS@123[root@training ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
3. TO CHECK CURRENT VERSION
mysql> SELECT VERSION();+-----------+
| VERSION() |
+-----------+
| 5.0.45 |
+-----------+
1 row in set (0.00 sec)
4.TO CHECK CURRENT DATE
mysql> SELECT CURRENT_DATE();+----------------+
| CURRENT_DATE() |
+----------------+
| 2012-06-09 |
+----------------+
1 row in set (0.00 sec)
5. TO RUN MULTI COMMAND IN ONE QUERY
mysql> SELECT VERSION(), CURRENT_DATE;+-----------+--------------+
| VERSION() | CURRENT_DATE |
+-----------+--------------+
| 5.0.45 | 2012-06-09 |
+-----------+--------------+
1 row in set (0.00 sec)
6. TO USE MYSQL AS A CALCULATER
mysql> select (4-5)*5;+---------+
| (4-5)*5 |
+---------+
| -5 |
+---------+
1 row in set (0.00 sec)
7. TO CHECK TIME WITH DATE
mysql> select now();+---------------------+
| now() |
+---------------------+
| 2012-06-09 22:29:35 |
+---------------------+
1 row in set (0.00 sec)
7. TO RUN THE STATEMENT IN MULTIPLR LINE
mysql> SELECT USER()-> ,
-> CURRENT_DATE
-> ;
+----------------+--------------+
| USER() | CURRENT_DATE |
+----------------+--------------+
| root@localhost | 2012-06-09 |
+----------------+--------------+
1 row in set (0.00 sec)
8. TO CANCEL AN CURRENT COMMAND, PRESS SMALL \C
mysql> select user-> ()
-> \c
mysql>
9. TO CHECK DATABASE INSIDE MYSQL
mysql> SHOW DATABASES;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
10. TO ACCESS THE DATABASE
mysql> USE testDatabase changed
mysql>
11. HOW TO CREATE DATABASE
mysql> CREATE DATABASE example._db;Query OK, 1 row affected (0.02 sec)
mysql>
12. TO GIVE PRIVILEGE FOR USER ON A PARTICULLAR DATABASE
mysql> grant CREATE,INSERT,DELETE,UPDATE,SELECT on example_db.* to user@localhost;Query OK, 0 rows affected (0.00 sec)
13. TO CREATE USER WITH PASSWORD
mysql> CREATE USER 'USER'@'localhost' IDENTIFIED BY 'password';Query OK, 0 rows affected (0.00 sec)
14. TO REMOVE/DROP USER IN MYSQL
mysql> drop user dev@localhost;Query OK, 0 rows affected (0.00 sec)
0 comments:
Post a Comment