MySQL: Sample Session
In this sample session,
- A session is started
- Databases are listed
- A new database is created
- A user is created
- Permissions are examined
- Permissions are dropped
FreeBSD> mysql -h localhost -p -u root
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 78 to server version: 4.1.10a
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
+----------+
1 rows in set (0.01 sec)
mysql>
mysql> create database testdb;
Query OK, 1 row affected (0.05 sec)
mysql>
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| testdb |
+----------+
2 rows in set (0.00 sec)
mysql>
mysql> grant all privileges on *.* to 'testuser'@'localhost' identified by 'testpass' with grant option;
Query OK, 0 rows affected (0.02 sec)
mysql> show grants for 'testuser'@'localhost';
+--------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for testuser@localhost |
+--------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'localhost' IDENTIFIED BY PASSWORD '*00E247AC5F9AF26AE0194B41E1E769DEE1429A29' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.05 sec)
mysql> revoke all privileges on *.* from 'testuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> revoke grant option on *.* from 'testuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for 'testuser'@'localhost';
+-----------------------------------------------------------------------------------------------------------------+
| Grants for testuser@localhost |
+-----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'testuser'@'localhost' IDENTIFIED BY PASSWORD '*00E247AC5F9AF26AE0194B41E1E769DEE1429A29' |
+-----------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> drop user 'testuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql>
|