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

mod_perl, mod_ssl, mod_wsgi

mod_perlは、Perl言語で記述されたプログラムを高速に実行できる機能を持った、apacheのモジュール。このモジュールを組み込むと、perlでapache APIを利用することができるようになる。

ApacheをSSL対応するためには、mod_sslとOpenSSLが必要。ApacheでSSL/TLSを利用するためのモジュールとしてmod_sslが利用されている。

mod_wsgiは、WSGI(Web Server Gateway Interface)インターフェイスに準拠したPythonのプログラムをApache HTTP Serverで動作させるためのモジュール。

sudo perl -MCPAN -e shell

http://www.cpan.org/SITES.html

setting url to get

Japan
ftp://ftp.nara.wide.ad.jp/pub/CPAN/
http://ftp.nara.wide.ad.jp/pub/CPAN/
rsync://ftp.nara.wide.ad.jp/cpan/

install Test::Pod
-> PODの書式に誤りがないかを確認する

install YAML
-> YAML形式のファイルを読み込む

install CGI
-> サーバ上で動作

install CGI::Session
-> CGIアプリケーションにおける持続的なデータのセッション

install Pod::Escapes
-> This module provides things that are useful in decoding Pod E<..> sequences. Presumably, it should be used only by Pod parsers and/or formatters.

install Pod::Simple
-> Pod::Simple is a Perl library for parsing text in the Pod (“plain old documentation”) markup language that is typically used for writing documentation for Perl and for Perl modules. The Pod format is explained in perlpod; the most common formatter is called perldoc.

install Jcode
-> 日本語文字集合ハンドラ。Jcode.pmはオブジェクト的なアプローチと従来のアプローチの両方をサポート。オブジェクト的なアプローチでは、 $iso_2022_jp = Jcode->new($str)->h2z->jis とすることもできる。

install Mail::Sendmail
-> Simple platform independent e-mail from your perl script. Only requires Perl 5 and a network connection. After struggling for some time with various command-line mailing programs which never what i wanted, i put together this perl only solution.

use Mail::Sendmail;
%mail = ( To => 'hoge@gmail.com',
          From => 'me@here.com',
          Message => 'This is very short message');
sendmail(%mail) or die %Mail::Sendmail::error;

print "OK, Log says:\n", $Mail::Sendmail::log;

install OLE::Storage_Lite
-> Simple Class for OLE document interface. allow you to read and write an OLE structured file. class representing PPS.

install Spreadsheet::ParseExcel
-> read information from an Excel file.

install Net::OpenSSH
-> OpenSSH is a secure shell client package implemented on top of OpenSSH binary client. This package is implemented around the multiplexing feature found in later version of OpenSSH.

install Capture::Tiny
-> Capture::Tiny provides a simple, portable way to capture almost anything sent to STDOUT or STDERR, regardless of whether it comes from Perl, from XS code or from an external program. Optionally, output can be teed so that it is captured whilebeig passed through to the original filehandles.

install Date::Calc
-> グレゴリオ暦に基づいた日付計算

install FCGI
-> CGI.pmによって作成されるCGIオブジェクトのサブクラス。 Open Market FastCGI標準でうまく機能するように特殊化されている。

install Time::HiRes
-> 高精度のalarm, sleep, gettimeofday, インターバル・タイマー。

install DBI
-> Database independent interface for Perl

install Text::CSV_XS
-> CSV形式の操作ルーチン。コンマ区切り文字列CSVを組み立てたり切り分けたりするのに便利な機能を提供する。フィールド群を連結してCSV文字列にしたり、パースしてフィールド群にすることができる。

install ExtUtils::MakeMaker
-> モジュール用Makefileの生成。Makefile.PLにおいて拡張モジュールのためのMakefileを書くために設計されている。

install DBD::mysql
-> MysqlのためのPerl DBIドライバ。

install IO::Stringy
-> I/O on in-core objects like strings and arrays. This toolkit primarily provides modules for performing both traditional and object oriented i/o on things.