Comments (5)
- アカウント作成
mysql> create user 'user1'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'user2'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'user3'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
- グローバルレベルで全権限を持つアカウント
mysql> grant all privileges on utfDB.* to 'user1'@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
- データベースレベルでSELECT権限のみを持つアカウント(DBは先ほど作成したものを指定)
mysql> grant select on utfDB.* to 'user2'@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
- データベースレベルでCREATE, ALTER, SELECT, DELETE権限を持つアカウント(DBは先ほど作成したものを指定)
mysql> grant create,alter,select,delete on utfDB.* to 'user3'@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
Ref.
http://www.dbonline.jp/mysql/user/index1.html
http://qiita.com/pinohara/items/481c95dc4c8c2568bf8d
from training.
共通
ユーザーを作成した後はユーザー一覧を、権限の付与を行った後はユーザーの持つ権限の確認を必ず行いましょう。
「グローバルレベルで全権限を持っているアカウント」
ここでいうグローバルレベルとは、「全てのDBに対する権限」という意味になります。
現在の記述では、utfDB
というデータベースレベルで全権限を持っていることになっています。
from training.
- アカウント作成
mysql> create user 'user1'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'user2'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'user3'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> select user, host, password from mysql.user;
+---------+-----------------+-------------------------------------------+
| user | host | password |
+---------+-----------------+-------------------------------------------+
| root | localhost | |
| root | ip-***-**-*-*** | |
| root | ***.*.*.* | |
| root | ::1 | |
| | localhost | |
| | ip-***-**-*-*** | |
| thori | ***-**-*-*** | password |
| issue24 | ip-***-**-*-*** | password |
| user1 | localhost | password |
| user2 | localhost | password |
| user3 | localhost | password|
+---------+-----------------+-------------------------------------------+
- グローバルレベルで全権限を持つアカウント
mysql> grant all on *.* to 'user1'@localhost identified by 'password';
Query OK, 0 rows affected (0.01 sec)
mysql> show grants for user1@localhost
-> ;
+-----------------------------------------------------------------------------------------------------------------------+
| Grants for user1@localhost |
+-----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'user1'@'localhost' IDENTIFIED BY PASSWORD 'password' |
| GRANT ALL PRIVILEGES ON `utfDB`.* TO 'user1'@'localhost' |
+-----------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
- データベースレベルでSELECT権限のみを持つアカウント(DBは先ほど作成したものを指定)
mysql> grant select on utfDB.* to 'user2'@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for user2@localhost;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user2@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user2'@'localhost' IDENTIFIED BY PASSWORD 'password' |
| GRANT SELECT ON `utfDB`.* TO 'user2'@'localhost' |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
- データベースレベルでCREATE, ALTER, SELECT, DELETE権限を持つアカウント(DBは先ほど作成したものを指定)
mysql> grant create,alter,select,delete on utfDB.* to 'user3'@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for user3@localhost;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user3@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user3'@'localhost' IDENTIFIED BY PASSWORD 'password' |
| GRANT SELECT, DELETE, CREATE, ALTER ON `utfDB`.* TO 'user3'@'localhost' |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
Ref.
http://www.dbonline.jp/mysql/user/index1.html
http://www.dbonline.jp/mysql/user/index5.html
http://qiita.com/pinohara/items/481c95dc4c8c2568bf8d
http://ftp.nchu.edu.tw/MySQL/doc/refman/5.1/ja/grant.html
from training.
確認しました、OKです!
from training.
確認しました、OKです。お疲れ様でしたー。
from training.
Related Issues (20)
- サーバサイド - フレームワーク - フレームワークとは HOT 3
- サーバサイド - フレームワーク - Laravel - インストールと設定 HOT 3
- サーバサイド - フレームワーク - Laravel - routingとview作成
- サーバサイド - フレームワーク - Laravel - テンプレートエンジンのBladeを使う HOT 2
- サーバサイド - フレームワーク - Laravel - Controller作成 HOT 1
- サーバサイド - フレームワーク - Laravel - フォームのバリデーション、CSRF対策 HOT 2
- フロントエンド - JavaScript/jQuery - JavaScript/jQueryを理解する HOT 3
- フロントエンド - JavaScript/jQuery - Hello World!
- フロントエンド - JavaScript/jQuery - 関数を作る
- フロントエンド - JavaScript/jQuery - DOM操作
- フロントエンド - JavaScript/jQuery - イベント操作
- フロントエンド - JavaScript/jQuery - 条件分岐
- フロントエンド - JavaScript/jQuery - ajax通信
- サーバサイド - サーバサイドテスト - 自動ユニットテストの基礎 HOT 3
- サーバサイド - PHP - PHPを理解する HOT 6
- サーバサイド - PHP - PHPを書く HOT 11
- サーバサイド - PHP - フォーム作成
- フロントエンド - JavaScriptTraining HOT 1
- ruby - 環境構築 HOT 8
- ruby - 基本構文 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from training.