権限
"benkyo"データベースを作成し(#2:データベース作成)、"testuser"ユーザーも作成した(#5:ユーザー作成)。
が、権限が無いためtestuserからbenkyoデータベースへアクセスできない。
testuserでログインし "SHOW DATABASES" コマンドを実行しても benkyo データベースは表示されない。
ということでtestuserにbenkyoデータベースの全権限を与えることにする。
コマンドプロンプトからrootユーザーでログインし、以下コマンドを実行する。
"GRANT ALL ON benkyo.* TO testuser@'localhost';" 実行結果:
これで権限が付与された筈なので testuserでログインし SHOW DATABASES を実行してみる。
benkyoが表示された。
"use benkyo" で benkyoデータベースに切り替えテーブルを作成してみる。
作成できた。
SHOW TABLESで確認してみる。
問題なし。
が、権限が無いためtestuserからbenkyoデータベースへアクセスできない。
testuserでログインし "SHOW DATABASES" コマンドを実行しても benkyo データベースは表示されない。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | C:\Windows\system32>mysql -u testuser -p Enter password: ******** Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 23 Server version: 10.5.9-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+ 2 rows in set (0.000 sec) |
コマンドプロンプトからrootユーザーでログインし、以下コマンドを実行する。
"GRANT ALL ON benkyo.* TO testuser@'localhost';" 実行結果:
1 2 | MariaDB [(none)]> GRANT ALL ON benkyo.* TO testuser@ 'localhost' ; Query OK, 0 rows affected (0.740 sec) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | C:\Windows\system32>mysql -u testuser -p Enter password: ******** Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 30 Server version: 10.5.9-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | benkyo | | information_schema | | test | +--------------------+ 3 rows in set (0.000 sec) |
"use benkyo" で benkyoデータベースに切り替えテーブルを作成してみる。
1 2 3 4 | MariaDB [(none)]> use benkyo Database changed MariaDB [benkyo]> create table testtable ( id int, name varchar(10)); Query OK, 0 rows affected (1.210 sec) |
SHOW TABLESで確認してみる。
1 2 3 4 5 6 7 | MariaDB [benkyo]> show tables; +------------------+ | Tables_in_benkyo | +------------------+ | testtable | +------------------+ 1 row in set (0.001 sec) |
MariaDB, MySQL
0 件のコメント:
コメントを投稿