Git Product home page Git Product logo

Comments (5)

thori0908 avatar thori0908 commented on August 11, 2024
  • アカウント作成
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.

fr-itaya avatar fr-itaya commented on August 11, 2024
共通

ユーザーを作成した後はユーザー一覧を、権限の付与を行った後はユーザーの持つ権限の確認を必ず行いましょう。

「グローバルレベルで全権限を持っているアカウント」

ここでいうグローバルレベルとは、「全てのDBに対する権限」という意味になります。
現在の記述では、utfDBというデータベースレベルで全権限を持っていることになっています。

from training.

thori0908 avatar thori0908 commented on August 11, 2024
  • アカウント作成
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.

fr-matsuo avatar fr-matsuo commented on August 11, 2024

確認しました、OKです!

from training.

fr-itaya avatar fr-itaya commented on August 11, 2024

確認しました、OKです。お疲れ様でしたー。

from training.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.