MariaDB 10.6.4で権限の確認と付与のサンプル

2022年9月3日

環境

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [testdb]> select version();
+----------------+
| version() |
+----------------+
| 10.6.4-MariaDB |
+----------------+
1 row in set (0.001 sec)
MariaDB [testdb]> select version(); +----------------+ | version() | +----------------+ | 10.6.4-MariaDB | +----------------+ 1 row in set (0.001 sec)
MariaDB [testdb]> select version();
+----------------+
| version() |
+----------------+
| 10.6.4-MariaDB |
+----------------+
1 row in set (0.001 sec)

操作方法
1.登録されているホストとユーザー名を確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------------+
| User | Host |
+-------------+-----------------+
| root | % |
| test05 | %.arkgame.com |
| root | 127.0.0.1 |
| test04 | 172.17.1.200 |
| test06 | 172.17.12.% |
| root | ::1 |
| test01 | arkgame.com |
MariaDB [(none)]> select user,host from mysql.user; +-------------+-----------------+ | User | Host | +-------------+-----------------+ | root | % | | test05 | %.arkgame.com | | root | 127.0.0.1 | | test04 | 172.17.1.200 | | test06 | 172.17.12.% | | root | ::1 | | test01 | arkgame.com |
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------------+
| User        | Host            |
+-------------+-----------------+
| root        | %               |
| test05      | %.arkgame.com   |
| root        | 127.0.0.1       |
| test04      | 172.17.1.200    |
| test06      | 172.17.12.%     |
| root        | ::1             |
| test01      | arkgame.com     |

2.特定のユーザーの権限を確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> show grants for 'test04'@'172.17.1.200';
+------------------------------------------------------------------------------------------------------------------+
| Grants for test04@172.17.1.200 |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `test04`@`172.17.1.200` IDENTIFIED BY PASSWORD '*84F9574D0CE7CEDFED996451B6926F824C94B242' |
+------------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)
MariaDB [(none)]> show grants for 'test04'@'172.17.1.200'; +------------------------------------------------------------------------------------------------------------------+ | Grants for test04@172.17.1.200 | +------------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO `test04`@`172.17.1.200` IDENTIFIED BY PASSWORD '*84F9574D0CE7CEDFED996451B6926F824C94B242' | +------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.000 sec)
MariaDB [(none)]> show grants for 'test04'@'172.17.1.200';
+------------------------------------------------------------------------------------------------------------------+
| Grants for test04@172.17.1.200                                                                                   |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `test04`@`172.17.1.200` IDENTIFIED BY PASSWORD '*84F9574D0CE7CEDFED996451B6926F824C94B242' |
+------------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)

3.権限の付与
書式
GRANT 権限 ON レベル TO ユーザ IDENTIFIED BY PASSWORD '****’
実行例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> grant select, update on testdb.* to 'root'@'localhost' identified by 'arkgame';
Query OK, 0 rows affected (0.086 sec)
MariaDB [(none)]> grant select, update on testdb.* to 'root'@'localhost' identified by 'arkgame'; Query OK, 0 rows affected (0.086 sec)
MariaDB [(none)]> grant select, update on testdb.* to 'root'@'localhost' identified by 'arkgame';
Query OK, 0 rows affected (0.086 sec)

 

MariaDB

Posted by arkgame