INFO 2015/08/19 14:48:38 harness.go:165: Listening on :9000 2015/08/19 14:48:40 server.go:1775: http: TLS handshake error from 127.0.0.1:36799: tls: first record does not look like a TLS handshake
SELECT ~ INTO OUTFILE output.csv の場合、DB サーバに /tmp/hoge.csv は出力される。 コマンド実行するサーバと DB サーバが異なる場合は注意が必要です。
1 2
use dbname SELECT * INTO OUTFILE'/tmp/hoge.csv' FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '' LINES STARTING BY '' TERMINATED BY '\r\n' FROM table;
コマンドライン SQL ファイルをロードし実行結果を CSV に保存
1
mysql -h <host> -u <user> -p<password> <db_name> -e "`cat query.sql`" | sed -e 's/\t/,/g' >/tmp/result.csv
ALTER TABLE product CHANGE `no` `id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商品ID';
インデックス一覧表示
1
SHOW INDEXES FROM <table>;
インデックス追加
1 2 3
ALTER TABLE <table> ADD INDEX <index name>(<column>);
ALTER TABLE <table> ADD INDEX <index name>(<column1>,<column2>);
インデックス削除
1
ALTER TABLE <table> DROP INDEX <index name>;
ユニーク追加
1
ALTER TABLE <table> ADD UNIQUE(<column>);
ユニーク削除
DB の文字コード確認
1
SHOW CREATE DATABASE dbname
gz 形式で圧縮状態のファイルを特定 DB スキーマへ実行
1
zcat dump.sql.gz | mysql -u <user> -p<password> dbname
全テーブルの統計情報をサイズ順に一覧表示
1
SELECT table_name, engine, table_rows AS tbl_rows, avg_row_length AS rlen, floor((data_length + index_length) / 1024 / 1024) AS allMB, floor((data_length) / 1024 / 1024) AS dMB, floor((index_length) / 1024 / 1024) AS iMB FROM information_schema.tables WHERE table_schema = database() ORDER BY (data_length + index_length) DESC;
テーブルの文字コード等確認
1 2 3 4 5 6 7
SELECT * FROM information_schema.schemata WHERE schema_name = 'database_name';
# openssl req -new -sha256 -key server.key -out server.csr Enter pass phrase for server.key: v6biM9MMByBO0SWFitcbnyF0VUsJLbZsizpP7K15
You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:JP State or Province Name (full name) []:Tokyo Locality Name (eg, city) [Default City]:Setagaya-ku Organization Name (eg, company) [Default Company Ltd]:UmiyamaShouji inc. Organizational Unit Name (eg, section) []:Production Common Name (eg, your name or your server's hostname) []:ec2-xx-xx-xx-xx.ap-northeast-1.compute.amazonaws.com Email Address []: (空白のままEnter)
Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: (空白のままEnter) An optional company name []: (空白のままEnter)
確認
1 2 3 4 5 6
$ ls -al total 8 drwxr-xr-x. 2 root root 40 Aug 5 13:43 . drwxr-xr-x. 3 root root 17 Aug 5 13:32 .. -rw-r--r--. 1 root root 729 Aug 5 13:43 server.csr -rw-r--r--. 1 root root 963 Aug 5 13:37 server.key
RSA key作成
1 2
# openssl rsa -in server.key -out server.key Enter pass phrase for server.key: v6biM9MMByBO0SWFitcbnyF0VUsJLbZsizpP7K15
nginx.service - nginx - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled) Active: active (running) since Mon 2015-08-03 06:07:44 UTC; 2s ago Docs: http://nginx.org/en/docs/ Process: 12642 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) Process: 12641 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) Main PID: 12645 (nginx) CGroup: /system.slice/nginx.service ├─12645 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.... └─12646 nginx: worker process
Aug 03 06:07:44 ip-172-31-19-253 systemd[1]: Starting nginx - high performan.... Aug 03 06:07:44 ip-172-31-19-253 nginx[12641]: nginx: the configuration file...k Aug 03 06:07:44 ip-172-31-19-253 nginx[12641]: nginx: configuration file /et...l Aug 03 06:07:44 ip-172-31-19-253 systemd[1]: Failed to read PID from file /r...t Aug 03 06:07:44 ip-172-31-19-253 systemd[1]: Started nginx - high performanc.... Hint: Some lines were ellipsized, use -l to show in full.
Nginx 設定ファイル修正
1
# vim /etc/nginx/conf.d/default.conf
1 2 3 4 5 6 7
server { listen 80; server_name ec2-xx-xx-xx-xxx.ap-northeast-1.compute.amazonaws.com;