MariaDB 10.6にホスト名を指定しユーザーを作成する
環境
Windows 10 64bit
MariaDB 10.6.4
書式
create user ユーザー名@ホスト名 identified by 'パスワード’
ユーザー名と接続を行うクライアントのホスト名の組み合わせて指定します。
異なるホストからログインできません。
ユーザー名とホスト名を指定する形式
'test’@’arkgame.com’
“test"@"arkgame.com"
test@arkgame.com
`test`@`arkgame.com`
'test’@’172.17.1.200’
'test’@’%.arkgame.com’
'test’@’172.17.12.%’
操作例1
ユーザー「test01」を作成します
MariaDB [(none)]> create user 'test01’@’arkgame.com’ identified by '123#a’;
Query OK, 0 rows affected (0.053 sec)
ユーザー「test01」作成後確認
MariaDB [(none)]> select user,host from mysql.user where user="test01"; +--------+-------------+ | User | Host | +--------+-------------+ | test01 | arkgame.com | +--------+-------------+ 1 row in set (0.001 sec)
操作例2
ユーザー「test02」を作成します
MariaDB [(none)]> create user “test02″@"arkgame.com" identified by '123#a’;
Query OK, 0 rows affected (0.066 sec)
ユーザー「test02」作成後確認
MariaDB [(none)]> select user,host from mysql.user where user="test02"; +--------+-------------+ | User | Host | +--------+-------------+ | test02 | arkgame.com | +--------+-------------+ 1 row in set (0.001 sec)
操作例3
ユーザー「test03」を作成します
MariaDB [(none)]> create user test03@arkgame.com identified by '123#a’;
Query OK, 0 rows affected (0.043 sec)
ユーザー「test03」作成後確認
MariaDB [(none)]> select user,host from mysql.user where user="test03"; +--------+-------------+ | User | Host | +--------+-------------+ | test03 | arkgame.com | +--------+-------------+ 1 row in set (0.001 sec)
操作例4
ユーザー「test04」を作成します
MariaDB [(none)]> create user 'test04’@’172.17.1.200’ identified by '123#a’;
Query OK, 0 rows affected (0.023 sec)
ユーザー「test04」作成後確認
MariaDB [(none)]> select user,host from mysql.user where user="test04"; +--------+--------------+ | User | Host | +--------+--------------+ | test04 | 172.17.1.200 | +--------+--------------+ 1 row in set (0.001 sec)
操作例5
ユーザー「test05」を作成します
MariaDB [(none)]> create user 'test05’@’%.arkgame.com’ identified by '123#a’;
Query OK, 0 rows affected (0.112 sec)
ユーザー「test05」作成後確認
MariaDB [(none)]> select user,host from mysql.user where user="test05"; +--------+---------------+ | User | Host | +--------+---------------+ | test05 | %.arkgame.com | +--------+---------------+ 1 row in set (0.001 sec)
操作例6
MariaDB [(none)]> create user 'test06’@’172.17.12.%’ identified by '123#a’;
Query OK, 0 rows affected (0.087 sec)
ユーザー「test06」作成後確認
MariaDB [(none)]> select user,host from mysql.user where user="test06"; +--------+-------------+ | User | Host | +--------+-------------+ | test06 | 172.17.12.% | +--------+-------------+ 1 row in set (0.004 sec)