Open2
MySQLに読み取り権限ユーザーを作成する
概要
- 本番環境やstg環境のデータベースに読み取り権限でアクセスできるようにする
コマンド
MySQL [ebdb]> CREATE USER 'readonly'@'%' IDENTIFIED BY 'xxx';
Query OK, 0 rows affected (0.045 sec)
MySQL [ebdb]> GRANT SELECT ON ebdb.* TO 'readonly'@'%';
Query OK, 0 rows affected (0.007 sec)
MySQL [ebdb]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.009 sec)
だめだったコマンド
MySQL [ebdb]> GRANT SELECT ON *.* TO readonly@'%' IDENTIFIED BY 'xxx';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'xxx'' at line 1
MySQL [ebdb]>
MySQL [ebdb]> GRANT SELECT ON *.* TO 'readonly'@'%' IDENTIFIED BY 'xxx';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'xxx'' at line 1