Skip to content

Instantly share code, notes, and snippets.

@na0AaooQ
Last active March 24, 2019 23:21
Show Gist options
  • Save na0AaooQ/110029fb9e4d0fcf98a0 to your computer and use it in GitHub Desktop.
Save na0AaooQ/110029fb9e4d0fcf98a0 to your computer and use it in GitHub Desktop.
Amazon RDS for MySQLインスタンス作成手順 ref: https://qiita.com/na0AaooQ/items/7c69a88c80f1efb4cad3
[ec2-user@example-server ~]$ mysql -u example_user -p -h example-rds-mysql-server.carvmoii2uds.ap-northeast-1.rds.amazonaws.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.6.27-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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> \q
[ec2-user@example-server ~]$ sudo yum -y install mysql
[ec2-user@example-server ~]$ mysql -u example_user -p -h example-rds-mysql-server.carvmoii2uds.ap-northeast-1.rds.amazonaws.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.6.27-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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> CREATE TABLE `exampledb`.`example_table`( `id` int(12), `insert_date` datetime ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.02 sec)
mysql> SELECT * FROM exampledb.example_table;
Empty set (0.00 sec)
mysql> SELECT now();
+---------------------+
| now() |
+---------------------+
| 2016-02-20 17:30:15 |
+---------------------+
1 row in set (0.00 sec)
mysql> SET SESSION time_zone = 'Asia/Tokyo';
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT now();
+---------------------+
| now() |
+---------------------+
| 2016-02-21 02:30:21 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM exampledb.example_table;
Empty set (0.01 sec)
mysql> INSERT INTO exampledb.example_table( id, insert_date) VALUES( 1, now() );
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM exampledb.example_table;
+------+---------------------+
| id | insert_date |
+------+---------------------+
| 1 | 2016-02-21 02:30:31 |
+------+---------------------+
1 row in set (0.01 sec)
mysql> \q
Bye
[ec2-user@example-server ~]$
[ec2-user@example-server ~]$ mysql -u root -p -h example-rds-mysql-server.carvmoii2uds.ap-northeast-1.rds.amazonaws.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.6.27-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON exampledb.* TO example_user@'198.51.100.0/255.255.255.0' IDENTIFIED BY '**************';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON exampledb.* TO example_user@'192.0.2.0/24/255.255.255.0' IDENTIFIED BY '**************';
Query OK, 0 rows affected (0.01 sec)
mysql> SELECT user, host FROM mysql.user WHERE user = 'example_user';
+--------------+----------------------------+
| user | host |
+--------------+----------------------------+
| example_user | 192.0.2.0/24/255.255.255.0 |
| example_user | 198.51.100.0/255.255.255.0 |
+--------------+----------------------------+
2 rows in set (0.00 sec)
mysql> \q
[ec2-user@example-server ~]$ mysql -u root -p -h example-rds-mysql-server.carvmoii2uds.ap-northeast-1.rds.amazonaws.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.6.27-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
mysql> SELECT version();
+------------+
| version() |
+------------+
| 5.6.27-log |
+------------+
1 row in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| exampledb |
| innodb |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 rows in set (0.00 sec)
mysql> \q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment