Character string values storage:
1. CHAR:
§ Stores strings of fixed length.
§ The length parameter s specifies the length of the strings.
§ If the string has smaller length it padded with
 space at the end
§ It will waste of a lot of disk space.
§ If the string has bigger length it truncated to the scale number of the string.

2. VARCHAR:
§ Stores strings of variable length.
§ The length parameter specifies the maximum length of the strings
§ It stores up to 2000 bytes of characters
§ It will occupy space for NULL values
§ The total length for strings is defined when database was created.

3. VARCHAR(2):
§ Stores strings of variable length.
§ The length parameter specifies the maximum length of the strings
§ It stores up to 4000 bytes of characters
§ It will not occupy space for NULL values
§ The total length of strings is defined when strings are given



Read more:
 http://wiki.answers.com/Q/What_is_difference_between_varchar_and_varchar2#ixzz1y8EQfB7P

mysql error log, slow log의 경우에는 log rotate가 되지 않기 때문에 로그량이 많을 경우 파일을 열기 힘들어질 수 있다.

이에 대비하여 log rotate 설정을 한다.

 

샘플 파일은 $MYSQL_HOME/support-files/mysql-log-rotate 이다.

 

1. mysql-log-rotate 파일을 작성하고 /etc/logrotate.d 에 복사한다.

여기서는 error log 와 slow log 두가지를 rotate 할 것이므로 로그 위치에 따라 두번 작성하였다.

필요에 따라 rotate 보관 및 삭제 주기, 파일 위치 등 상세 설정은 변경해주어야 한다.

 

vi /etc/logrotate.d/mysql-log-rotate

 

-------------------------------------------------------------------

# This logname can be set in /etc/my.cnf
# by setting the variable "err-log"
# in the [safe_mysqld] section as follows:
#
# [safe_mysqld]
# err-log=/usr/local/mysql/data/mysqld.log
#
# If the root user has a password you have to create a
# /root/.my.cnf configuration file with the following
# content:
#
# [mysqladmin]
# password =
# user= root
#
# where "" is the password.
#
# ATTENTION: This /root/.my.cnf should be readable ONLY
# for root !

/mysql_log01/error/mysqld.err {
# create 600 mysql mysql
notifempty
monthly
rotate 13
missingok
# compress
postrotate
# just if mysqld is really running
if test -x /mw/mysql/mysql/bin/mysqladmin && \
/mw/mysql/mysql/bin/mysqladmin ping &>/dev/null
then
/mw/mysql/mysql/bin/mysqladmin --local flush-error-log \
flush-slow-log
fi
endscript
}

/mysql_log01/slow/mysvc01-slow.log {
# create 600 mysql mysql
notifempty
monthly
rotate 13
missingok
# compress
postrotate
# just if mysqld is really running
if test -x /mw/mysql/mysql/bin/mysqladmin && \
/mw/mysql/mysql/bin/mysqladmin ping &>/dev/null
then
/mw/mysql/mysql/bin/mysqladmin --local flush-error-log \
flush-slow-log
fi
endscript
}

-------------------------------------------------------------------

 

 

2. root 계정에서 DB 접속을 위한 정보 파일을 만든다.

 

vi /root/.my.cnf

------------------------

[mysqladmin]
password = ******
user= root

------------------------

 

 

3. 파일의 권한을 확인한다.

샘플 파일을 복사하여 작성한 경우에는 파일 권한이 755 이므로 이를 644 로 변경해주어야 한다.

 

ls -al /etc/logrotate.d/mysql-log-rotate

chmod -x /etc/logrotate.d/mysql-log-rotate

 

 

4. log rotate 가 정상적으로 되는지 확인한다.

 

logrotate -v /etc/logrotate.d/mysql-log-rotate

(또는 강제로 rotate 를 시키고 싶을 경우에는 -f 옵션을 추가하여 실행한다.)

'Database & SQL > MariaDB & MySQL' 카테고리의 다른 글

metadata_lock_info  (0) 2022.05.23
MariaDB 10.2 vs MySQL 8.0 SQL_MODE 비교  (0) 2019.07.23

 - mysql 8.0 default
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

 - maria 10.2 default
STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

 - mariadb 10.2 
 - sql_mode = "ONLY_FULL_GROUP_BY" 시
ONLY_FULL_GROUP_BY

 - mariadb 10.2 
 - sql_mode = "TRADITIONAL,ONLY_FULL_GROUP_BY" 시
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

 - mariadb 10.2 
 - sql_mode = "TRADITIONAL" 시
STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

'Database & SQL > MariaDB & MySQL' 카테고리의 다른 글

metadata_lock_info  (0) 2022.05.23
mysql-log-rotate  (0) 2019.09.20

+ Recent posts