「MySQL入門」ユーザ作成、削除と権限の設定コマンドまとめ

1.ユーザ作成
CREATE USER ‘testuser’@’localhost’ IDENTIFIED BY ‘667788’;
CREATE USER ‘testuser2’@’172.12.2.100_’ IDENDIFIED BY ‘667788’;
CREATE USER ‘testuser2’@’%’ IDENTIFIED BY ‘667788’;
CREATE USER ‘testuser2’@’%’ IDENTIFIED BY ”;
CREATE USER ‘testuser2’@’%’;

2.権限の設定
GRANT SELECT, INSERT ON test.user TO ‘testuser2’@’%’;
GRANT ALL ON *.* TO ‘testuser2’@’%’;

3.ユーザーのパスワードの設定
SET PASSWORD FOR ‘testuser2’@’%’ = PASSWORD(“667788”);

4.権限の削除
REVOKE SELECT ON *.* FROM ‘testuser2’@’%’;

5.ユーザーの削除
DROP USER ‘username’@’host’;