8-1-4 データベース作成
「2php版 インストールマニュアル.pdf」の「3 データベース作成」を参考にします。
MySQL のデータベースを確認します。
[root@centos6 saigai_archivesystem-package-1.5]# cd
[root@centos6 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | ecomgware | | mysql | +--------------------+ 3 rows in set (0.02 sec)
MySQL ユーザを確認します。
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> SELECT user, host FROM user; +-------+-----------+ | user | host | +-------+-----------+ | root | 127.0.0.1 | | gware | localhost | | root | localhost | +-------+-----------+ 3 rows in set (0.00 sec)
サーバ(ホスト)名は、「localhost」、「127.0.0.1」、または、次のコマンドで確認します。
mysql> show variables like 'hostname'; +---------------+--------------------+ | Variable_name | Value | +---------------+--------------------+ | hostname | centos6.myhome.net | +---------------+--------------------+ 1 row in set (0.00 sec)
MySQL 接続ユーザ、接続パスワード
データベースに接続するユーザを次のコマンドで作成します。
mysql> CREATE USER 'archive'@'localhost' IDENTIFIED BY 'archive';
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT user, host FROM mysql.user;
+---------+-----------+ | user | host | +---------+-----------+ | root | 127.0.0.1 | | archive | localhost | | gware | localhost | | root | localhost | +---------+-----------+ 4 rows in set (0.00 sec)
mysql> show grants for 'archive'@'localhost';
+----------------------------------------------------------------------------------------------------------------+ | Grants for archive@localhost | +----------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'archive'@'localhost' IDENTIFIED BY PASSWORD '*3BECC611393C6A398B2E97D113CB90B7B3340011' | +----------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
MySQL データベース
ecomarchive というデータベースを作成します。
mysql> CREATE DATABASE ecomarchive;
Query OK, 1 row affected (0.00 sec)
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | ecomarchive | | ecomgware | | mysql | +--------------------+ 4 rows in set (0.00 sec)
gware ユーザで ecomgware データベースに接続します。gware ユーザに ecomgware データベース権限を適用します。
mysql> GRANT all ON ecomarchive.* TO 'archive'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for 'archive'@'localhost'; +----------------------------------------------------------------------------------------------------------------+ | Grants for archive@localhost | +----------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'archive'@'localhost' IDENTIFIED BY PASSWORD '*3BECC611393C6A398B2E97D113CB90B7B3340011' | | GRANT ALL PRIVILEGES ON `ecomarchive`.* TO 'archive'@'localhost' | +----------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)
archive ユーザで ecomarchive データベースに接続します。
mysql> quit
Bye
[root@centos6 ~]# mysql -u archive -p ecomarchive
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quit
Bye
0 件のコメント:
コメントを投稿