| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

MySQL 簡易設定

提供: MyMemoWiki
2020年2月16日 (日) 04:29時点におけるPiroto (トーク | 投稿記録)による版
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

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)