Last active
November 24, 2016 03:49
-
-
Save nishinoshake/43e4bb3ab2abbbb9ff74 to your computer and use it in GitHub Desktop.
mysqlで新規DBの作成とか
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* create datebase utf-8 | |
* 文字コードを指定してDB作成 | |
*/ | |
CREATE DATABASE dbname CHARACTER SET utf8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* create user | |
* ユーザ作成 | |
*/ | |
CREATE USER username@'127.0.0.1' IDENTIFIED BY 'password'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ユーザ作成と権限付与をまとめて | |
*/ | |
GRANT ALL ON dbname.* TO username@'127.0.0.1' IDENTIFIED BY 'password'; | |
GRANT ALL ON dbname.* TO username@'%' IDENTIFIED BY 'password'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* データベースを削除 | |
*/ | |
DROP DATABASE dbname; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* REVOKE grant | |
* ユーザから権限剥奪 | |
*/ | |
REVOKE ALL PRIVILEGES ON dbname.* FROM username@'127.0.0.1'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* drop user | |
* ユーザ削除 | |
*/ | |
DROP USER username; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* grant all to database | |
* ユーザにデータベースへのすべての権限付与 | |
* GRANT ALL ON すべての権限を追加する | |
* dbname.* (dbnameデータベースの).(すべてのテーブルに) | |
* username@'127.0.0.1' ユーザ名@ホスト | |
* IDENTIFIED BY 'xxx' パスワードはxxx | |
*/ | |
GRANT ALL ON dbname.* TO username@'127.0.0.1'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ユーザのテーブルを取得 | |
*/ | |
select User, Host from mysql.user; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* show grant | |
* ユーザの権限を確認 | |
*/ | |
SHOW GRANTS FOR username@'127.0.0.1'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment