Last active
January 5, 2016 01:13
-
-
Save ishtaka/d9c7b73ec3cbeedae1c0 to your computer and use it in GitHub Desktop.
[MySQL]MySQL:データベースとユーザの作成
This file contains 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
# ルートユーザのパスワード設定 | |
SET PASSWORD FOR root@localhost=PASSWORD('**password**'); | |
# MySQLに接続できるユーザの表示 | |
USE mysql | |
SELECT host,user,password from user; | |
# パスワード無しのユーザ(匿名ユーザ)の削除 | |
DELETE FROM user WHERE user=""; | |
# データベースの作成 | |
CREATE DATABASE IF NOT EXISTS db_name CHARACTER SET char_set; | |
# 管理ユーザ作成(DB-level) | |
GRANT all ON db_name.* to 'username@hostname' IDENTIFIED BY '**password**'; | |
# 一般ユーザ作成(DB-level) | |
GRANT select,update,delete,insert ON db_name.* to 'username@hostname' IDENTIFIED BY '**password**'; | |
# 設定を反映する | |
flush privileges; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment