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