MySQL 簡易設定
ナビゲーションに移動
検索に移動
目次
MySQL 簡易設定
インストール
# 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)
© 2006 矢木浩人