[root@centos ~]# mysql -u root -p ← MySQLへrootでログイン
Enter password: ← MySQLのrootパスワード応答
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19 to server version: 4.1.12
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> grant all privileges on test.* to centos@localhost identified by 'centospass';
← testデータベースへの全てのアクセス権限を持った、新規ユーザcentosを登録
Query OK, 0 rows affected (0.00 sec)
mysql> select user from mysql.user where user='centos'; ← centosユーザ登録確認
+--------+
| user |
+--------+
| centos |
+--------+
1 row in set (0.00 sec)
mysql> exit ← ログアウト
Bye
[root@centos ~]# mysql -u centos -pcentospass ← centosユーザでMySQLサーバーへログイン
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18 to server version: 4.1.12
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database test; ← testデータベース作成
Query OK, 1 row affected (0.00 sec)
mysql> show databases; ← データベース作成確認
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.01 sec)
mysql> use test ← testデータベースへ接続
Database changed
mysql> create table test(num int, name varchar(50)); ← testテーブル作成
Query OK, 0 rows affected (0.01 sec)
mysql> show tables; ← テーブル作成確認
+----------------+
| Tables_in_test |
+----------------+
| test |
+----------------+
1 row in set (0.00 sec)
mysql> insert into test values(1,'山田太郎'); ← testテーブルへデータ登録
Query OK, 1 row affected (0.00 sec)
mysql> select * from test; ← データ登録確認
+------+----------+
| num | name |
+------+----------+
| 1 | 山田太郎 |
+------+----------+
1 row in set (0.00 sec)
mysql> update test set name='山田次郎'; ← testテーブル内データ更新
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from test; ← データ更新確認
+------+----------+
| num | name |
+------+----------+
| 1 | 山田次郎 |
+------+----------+
1 row in set (0.01 sec)
mysql> delete from test where num=1; ← testテーブル内データ削除
Query OK, 1 row affected (0.03 sec)
mysql> select * from test; ← データ削除確認
Empty set (0.00 sec)
mysql> drop table test; ← testテーブル削除
Query OK, 0 rows affected (0.00 sec)
mysql> show tables; ← テーブル削除確認
Empty set (0.00 sec)
mysql> drop database test; ← データベースtest削除
Query OK, 0 rows affected (0.00 sec)
mysql> show databases; ← データベース削除確認
+----------+
| Database |
+----------+
| mysql |
+----------+
1 row in set (0.00 sec)
mysql> exit ← ログアウト
Bye
[root@centos ~]# mysql -u root -p ← MySQLへrootでログイン
Enter password: ← MySQLのrootパスワード応答
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21 to server version: 4.1.12
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> revoke all privileges on *.* from centos@localhost; ← centosユーザから全てのデータベースへのアクセス権限を剥奪
Query OK, 0 rows affected (0.00 sec)
mysql> delete from mysql.user where user='centos' and host='localhost'; ← centosユーザ削除
Query OK, 1 row affected (0.01 sec)
mysql> select user from mysql.user where user='centos'; ← centosユーザ削除確認
Empty set (0.00 sec)
mysql> flush privileges; ← centosユーザの削除をMySQLサーバーへ反映
Query OK, 0 rows affected (0.01 sec)
mysql> exit ← ログアウト
Bye
|
|