Perl Internal Server Error

test.cgi

#!/usr/bin/perl --
use strict;
use utf8;

print "Content-type:text/html\n\n";
print "<html>\n";
print "<head></head>\n";
print "<h1>Hello World</h1>";
print "</html>";

Internal Server Errorが表示されたら、
file permissionを644から755に変更する

RDSのbinlog

https://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.MySQL.html

MySQL エラーログ、スロークエリログ、一般ログをモニタリングできます。MySQL エラーログはデフォルトで生成されます。DB パラメータグループのパラメーターを設定することで、スロークエリと一般ログを生成できます。Amazon RDS では、すべての MySQL ログファイルはローテーションされます。次に、ログファイルのタイプごとのローテーション間隔を示します。

うむ、わかった。

MySQL バイナリログ形式を設定するには
https://console.aws.amazon.com/rds/ にある Amazon RDS コンソールを開きます。
ナビゲーションペインで、[パラメータグループ] を選択します。
変更する DB インスタンスで使用するパラメータグループを選択します。
デフォルトのパラメータグループを変更することはできません。DB インスタンスがデフォルトのパラメータグループを使用している場合、新しいパラメータグループを作成し DB インスタンスと関連付けます。
DB パラメーターグループの詳細については、「DB パラメータグループを使用する」を参照してください。
[Parameter group actions (パラメータグループのアクション)] で、[Edit (編集)] を選択します。
binlog_format パラメータを、選択したバイナリログ記録形式 (ROW、STATEMENT、または MIXED) に設定します。
[変更の保存] を選択して、更新を DB パラメータグループに保存します。
重要
default.mysql5.6、default.mysql5.7、または default.mysql8.0 DB パラメータグループを変更すると、そのパラメータグループを使用するすべての MySQL バージョン DB インスタンスに影響を与えます。AWS リージョン内の特定の MySQL 5.6、5.7 または 8.0 DB インスタンスに別のバイナリログ形式を指定する場合は、独自の DB パラメータグループを作成します。このパラメータグループで、別のログ形式を指定し、その独自の DB パラメータグループを目的の DB インスタンスに割り当てます。

Amazon RDS では、通常、バイナリログはできる限り早く消去されますが、mysqlbinlog によってアクセスされるバイナリログはインスタンスで保持される必要があります。RDS でバイナリログを保持する時間数を指定するには、mysql.rds_set_configuration ストアドプロシージャを使用して、ログのダウンロードするのに十分な期間を指定します。保持期間を設定したら、DB インスタンスのストレージ使用状況をモニタリングして、保持されたバイナリログに必要以上の容量が使用されないようにします。

binlog retention hours の最大値はMySQLの場合は168時間(7日)
https://qiita.com/kooohei/items/90a1ad7d3e83b1e941ec

MySQL 5.6
MySQL 5.7
MySQL 8.0
バイナリログの保持時間-> デフォルト値はNULL(保持しない)、5分程度で削除されてしまう
binlog retention hours の最大値はMySQLの場合は168時間(7日) 以下のコマンドで実行できる
call mysql.rds_set_configuration(‘binlog retention hours’, 24);
https://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/mysql_rds_set_configuration.html

mysql log variation

-Error log
-General Query log
-Binary log
-Slow query log

Error log
The error log, which is also called system logging, log the startup, execution, stop logging of mysqld(server) error information of the problem that occurred, and so on.

cat /etc/my.cnf
log-error=/var/log/mysqld.log
cat /var/log/mysqld.log

General Query log
The general query log is also called query (SQL) logging, and mysqld (server) logs the connection with the client and the query (SQL) executed.

Binary log
Binary logs are also called binary (backup) logging and log statements of mysqld(server) data change as binary information. It is also used for replication.

-sample

log_bin="/var/log/mysql/bin.log"
log_bin_index="/var/log/mysql/bin.list"
max_binlog_size=1M
expire_logs_days=1

slow query log
Slow query logs are also referred to as slow query (debug) logging, logging of queries (SQL) that took longer than the number of seconds specified by long_query_time on mysqld (server) or queries that did not use index (SQL).

slow_query_log, general_log

mysql> show variables like ‘slow_query_log’;
+—————-+——-+
| Variable_name | Value |
+—————-+——-+
| slow_query_log | OFF |
+—————-+——-+
1 row in set (0.12 sec)

mysql> show variables like ‘general_log’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| general_log | OFF |
+—————+——-+
1 row in set (0.00 sec)

let disable new line by jQuery

prevent a line break

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<!-- 
<textarea name="sample" cols="50" rows="10" wrap="soft"></textarea> -->
<form>
<textarea name="sample" cols="50" rows="10" class="cancel"></textarea>
<input type="submit">
</form>

<script>
$('.cancel').bind('keydown', function(e){
	if(e.which == 13){
		return false;
	}
}).bind('blur', function(){
	var $textarea = $(this),
	text = $textarea.val(),
	new_text = text.replace(/\n/g, "");
	if(new_text!= text){
		$textarea.val(new_text);
	}
});
</script>

I can no longer break line when I press enter key within the textarea.

DELIMITER

With DELIMITER you can specify the end of SQL statement to another character, not “;”.

mysql> DELIMITER //
mysql> create definer = 'user'@'%' function 'msec'() returns char(26) charset sjis
    -> BEGIN
    -> return ( select replace(replace(Now(6), ' ','-'), ':', '.') from dual);
    -> END
    -> //
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''msec'() returns char(26) charset sjis
BEGIN
return ( select replace(replace(Now' at line 1

create table clog (
 CAMPAIGN_CODE char(5) NOT NULL,
 ENO char(40) NOT NULL,
 LINK_ITEM_NO char(3) NOT NULL,
 CLICKSTAMP char(26) NOT NULL,
 FREE1 varchar(253) DEFAULT NULL,
 FREE2 varchar(253) DEFAULT NULL,
 FREE3 varchar(253) DEFAULT NULL,
 FREE4 varchar(253) DEFAULT NULL,
 FREE5 varchar(253) DEFAULT NULL,
 FREE6 varchar(253) DEFAULT NULL,
 FREE7 varchar(253) DEFAULT NULL,
 FREE8 varchar(253) DEFAULT NULL,
 FREE9 varchar(253) DEFAULT NULL,
 FREE10 varchar(253) DEFAULT NULL,
 INSSTAMP char(26) NOT NULL,
 UPDSTAMP char(26) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=sjis;

create table cre (
 CAMPAIGN_CODE char(5) NOT NULL,
 LINO char(3) NOT NULL,
 START_DATE date NOT NULL,
 START_TIME char(4) NOT NULL,
 END_DATE date NOT NULL,
 END_TIME char(4) NOT NULL,
 MLURL varchar(512) NOT NULL,
 FREE1 varchar(253) DEFAULT NULL,
 FREE2 varchar(253) DEFAULT NULL,
 FREE3 varchar(253) DEFAULT NULL,
 FREE4 varchar(253) DEFAULT NULL,
 FREE5 varchar(253) DEFAULT NULL,
 FREE6 varchar(253) DEFAULT NULL,
 FREE7 varchar(253) DEFAULT NULL,
 FREE8 varchar(253) DEFAULT NULL,
 FREE9 varchar(253) DEFAULT NULL,
 FREE10 varchar(253) DEFAULT NULL,
 INSSTAMP char(26) NOT NULL,
 UPDSTAMP char(26) NOT NULL,
 PRIMARY KEY(CAMPAIGN_CODE, LINO),
 UNIQUE KEY SQL0123456(CAMPAIGN_CODE, LINO)
) ENGINE=InnoDB DEFAULT CHARSET=sjis;

DELIMITER
create definer = 'user'@'%' function 'msec'() returns char(26) charset sjis
BEGIN
  return ( select replace(replace(Now(6), ' ','-'), ':', '.') from dual);
END
//
DELIMITER ;


insert into cre (
 CAMPAIGN_CODE,
 LINO,
 START_DATE,
 START_TIME,
 END_DATE,
 ENT_TIME,
 MLURL,
 INSSTAMP,
 UPDSTAMP
) values (
 '00AF',
 '001',
 '2019-01-01',
 '0000',
 '2022-12-31',
 '2345',
 'http://localhost',
 '2019-01-01-00.00.00.000000',
 '2019-01-01-00.00.00.000000'
);

grant select, insert, execute on dev to ‘hoge@%’ indeintified by ‘password’

grant select, insert, update on ${table_name}.* to user@’%’ identified by ‘password’

mysql> create database dev;
Query OK, 1 row affected (0.14 sec)

mysql> use dev;
Database changed
mysql> grant select, insert, update, delete execute on dev.* to 'user'@'%' identified by 'password';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'execute on dev.* to 'user'@'%' identified by 'password'' at line 1
mysql> grant select, insert, update, delete, execute on dev.* to 'user'@'%' identified by 'password';
Query OK, 0 rows affected (0.19 sec)

ほーーーーーー

lower_case_table_names

MySQL has a variable named lower_case_table_names, which is a parameter that sets whether to distinguish case of table names.

0
Store database names and table names in uppercase and lowercase letters. The comparison of these names is also case sensitive. If the file system of the OS on which the MySQL server runs is case insensitive(eg OS X or windows), it should not be set to this value. If you set this value to 0 on such a file system and access the MyISAM table name by mixing case, sometimes the index may be destroyed.

1
Everything is rounded to lowercase when storing table names and database names. The comparison of names is case insensitive.

2
When storing the table name and database name, store it as it is (that is, store it-while preserving upper case letters and lower case letters). When looking up, these names are converted to lowercase letters, and comparison of names is done without distinguishing uppercase and lowercase letters. Note that this function work only on file systems that do not distinguish between uppercase and lowercase letters. The table name of InnoDB is stored in all lowercase letters as when setting lower_case_table_names = 1.

[vagrant@localhost ~]$ cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

character_set_server=utf8
default-storage-engine=InnoDB
innodb_file_per_table

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
user=mysql

# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
;plugin-load=rpl_semi_sync_master=semisync_master.so
# uncomment next line on SLAVE
;plugin-load=rpl_semi_sync_slave=semisync_slave.so

# Others options for Semisynchronous Replication
;rpl_semi_sync_master_enabled=1
;rpl_semi_sync_master_timeout=10
;rpl_semi_sync_slave_enabled=1

# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
;performance_schema

[mysql]
default-character-set=utf8

ないですね、ということはmy.cnfに追加できるってことかな。。

character_set_server

character_set_client: The sql statement issued on the client side becomes this character code
character_set_connection: converts characters received from the client into this character code
character_set_database: character code of the DB currently being referenced
character_set_results: The search result sent to the client is this character code
character_set_server: Default character code when creating DB
character_set_system: utf8 is always used in the character set used by the system

character-set-filesystem: file system character code