トップ 差分 一覧 ping ソース 検索 ヘルプ PDF RSS ログイン

MySQL 簡易設定



目次



記事一覧

キーワード

MySQL 簡易設定

[MySQL][Database]

 インストール

# yum install mysql-server

 起動

# /etc/rc.d/init.d/mysqld start

 利用

# mysql -u root -p

 設定

root パスワードの変更

mysql> set password for 'root'@'localhost' = password('newpassword');
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'krishna.typea.info' = password('newpassword');
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'127.0.0.1' = password('newpassword');
Query OK, 0 rows affected (0.00 sec)

ユーザーの作成

mysql> create user piroot@"%";
Query OK, 0 rows affected (0.00 sec)
mysql> create user piroot@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'piroot'@'localhost' = password('newpassword');
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'piroot'@'%' = password('newpassword');
Query OK, 0 rows affected (0.00 sec)

管理権限をユーザーに追加

mysql> grant all privileges on *.* to piroot@localhost identified by 'newpassword' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to piroot@"%" identified by 'newpassword' with grant option;
Query OK, 0 rows affected (0.00 sec)

権限を限定して追加

mysql> grant create,select,insert,update,delete on *.* to piroot@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> grant create,select,insert,update,delete on *.* to piroot@"%" identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> grant create,select,insert,update,delete on *.* to piroot@"%" identified by 'password';
Query OK, 0 rows affected (0.00 sec)

確認
mysql> select host, user from mysql.user;
+--------------------+--------+
| host               | user   |
+--------------------+--------+
| %                  | piroot | 
| 127.0.0.1          | root   | 
| krishna.typea.info |        | 
| krishna.typea.info | root   | 
| localhost          |        | 
| localhost          | piroot | 
| localhost          | root   | 
+--------------------+--------+
7 rows in set (0.00 sec)
データベースの作成
mysql> create database mt character set utf8;
Query OK, 1 row affected (0.10 sec)



YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto

Copyright© 矢木 浩人 All Rights Reserved.