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

MyMemoWiki

「MySQL 簡易設定」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
(ページの作成:「==MySQL 簡易設定== [MySQL][Database] ===インストール=== # yum install mysql-server ===起動=== # /etc/rc.d/init.d/mysqld start ===利用=== # mysql -…」)
 
 
(同じ利用者による、間の3版が非表示)
1行目: 1行目:
==MySQL 簡易設定==
+
==[[MySQL 簡易設定]]==
[MySQL][Database]
+
[[MySQL]] | [[Database]] |
 
===インストール===
 
===インストール===
 
  # yum install mysql-server
 
  # yum install mysql-server
9行目: 9行目:
 
===設定===
 
===設定===
 
====root パスワードの変更====
 
====root パスワードの変更====
  mysql> set password for 'root'@'localhost' = password('newpassword');
+
  mysql> set password for 'root'@'localhost' = password('newpassword');
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  mysql> set password for 'root'@'krishna.typea.info' = password('newpassword');
+
  mysql> set password for 'root'@'krishna.typea.info' = password('newpassword');
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  mysql> set password for 'root'@'127.0.0.1' = password('newpassword');
+
  mysql> set password for 'root'@'127.0.0.1' = password('newpassword');
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
 
====ユーザーの作成====
 
====ユーザーの作成====
  mysql> create user piroot@"%";
+
  mysql> create user piroot@"%";
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  mysql> create user piroot@localhost;
+
  mysql> create user piroot@localhost;
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  mysql> set password for 'piroot'@'localhost' = password('newpassword');
+
  mysql> set password for 'piroot'@'localhost' = password('newpassword');
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  mysql> set password for 'piroot'@'%' = password('newpassword');
+
  mysql> set password for 'piroot'@'%' = password('newpassword');
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
 
====管理権限をユーザーに追加====
 
====管理権限をユーザーに追加====
  mysql> grant all privileges on *.* to piroot@localhost identified by 'newpassword' with grant option;
+
  mysql> grant all pri[[vi]]leges on *.* to piroot@localhost identified by 'newpassword' with grant option;
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  mysql> grant all privileges on *.* to piroot@"%" identified by 'newpassword' with grant option;
+
  mysql> grant all pri[[vi]]leges on *.* to piroot@"%" identified by 'newpassword' with grant option;
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  
 
====権限を限定して追加====
 
====権限を限定して追加====
  mysql> grant create,select,insert,update,delete on *.* to piroot@localhost identified by 'password';
+
  mysql> grant create,select,insert,update,delete on *.* to piroot@localhost identified by 'password';
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  mysql> grant create,select,insert,update,delete on *.* to piroot@"%" identified by 'password';
+
  mysql> grant create,select,insert,update,delete on *.* to piroot@"%" identified by 'password';
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  mysql> grant create,select,insert,update,delete on *.* to piroot@"%" identified by 'password';
+
  mysql> grant create,select,insert,update,delete on *.* to piroot@"%" identified by 'password';
 
  Query OK, 0 rows affected (0.00 sec)
 
  Query OK, 0 rows affected (0.00 sec)
  
 
=====確認=====
 
=====確認=====
  mysql> select host, user from mysql.user;
+
  mysql> select host, user from mysql.user;
 
  +--------------------+--------+
 
  +--------------------+--------+
 
  | host              | user  |
 
  | host              | user  |
53行目: 53行目:
 
  7 rows in set (0.00 sec)
 
  7 rows in set (0.00 sec)
 
=====データベースの作成=====
 
=====データベースの作成=====
  mysql> create database mt character set utf8;
+
  mysql> create database mt character set utf8;
 
  Query OK, 1 row affected (0.10 sec)
 
  Query OK, 1 row affected (0.10 sec)

2020年2月16日 (日) 04:29時点における最新版

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)