데이터베이스 내 각 테이블 용량 확인(내림차순)
# DataBase/Mysql(MariaDB)2023. 12. 20. 16:06데이터베이스 내 각 테이블 용량 확인(내림차순)

SELECT table_name AS "테이블명", round(((data_length + index_length) / 1024 / 1024), 2) AS "테이블 용량(MB)" FROM information_schema.tables WHERE table_schema = 'your_database_name' ORDER BY (data_length + index_length) DESC;

유니온쿼리(Union Query)이용 결과값(Result Value) 합치기(Sum)
# DataBase/Mysql(MariaDB)2023. 1. 30. 13:57유니온쿼리(Union Query)이용 결과값(Result Value) 합치기(Sum)

유니온쿼리를 이용해서 아래와 같이 2개의 결과값을 합쳐야할 경우 아래와 같이 하면됩니다. MariaDB [darksharavim]> SELECT count(*) as cnt FROM `wp_usermeta`; +-----+ | cnt | +-----+ | 41 | +-----+ 1 row in set (0.001 sec) MariaDB [darksharavim]> SELECT count(*) as cnt FROM `wp_postmeta`; +-----+ | cnt | +-----+ | 39 | +-----+ 1 row in set (0.001 sec) MariaDB [darksharavim]> select sum(cnt) from ( -> SELECT count(*) as cnt FROM `wp_user..

mysql binary log 설정
# DataBase/Mysql(MariaDB)2022. 11. 22. 11:37mysql binary log 설정

mysql 바이너리 로그는 쿼리 수행을 로그로 남기는것. 로그 백업으로 사용되어 복구할때도 쓰일 수도 있으며, Replication 사용시 동기화에도 사용이 됨. binary 주요 파라미터 정보 파라미터값 (value) 설 명 (description) log-bin 바이너리 로그 경로 binlog_cache_size 바이너리 로그 캐시 사이즈 max_binlog_size 바이너리 로그 최대 사이즈 expire_logs_days 보관기간 binlog_format 바이너리 로그 포맷(binary logging format - mixed recommended) statement 쿼리문으로 기록되는 형식이고 용량을 적게 차지합니다. 버전 특성을 타지 않습니다.(sysdate()와 now()의 결과가 다른경우 등..

ERROR 1449 (HY000): The user specified as a definer ('mariadb.sys'@'localhost') does not exist
# DataBase/Mysql(MariaDB)2022. 11. 15. 14:32ERROR 1449 (HY000): The user specified as a definer ('mariadb.sys'@'localhost') does not exist

아래와 같이 불필요한 계정정리를 위해 쿼리를 실행하고 나서부터 아래와 같이 에러발생! MariaDB [mysql]> delete from user where password=''; [darksharavim]# /apps/mysql/bin/mysql -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 10.5.18-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Ty..

mysql slow query 설정
# DataBase/Mysql(MariaDB)2022. 11. 11. 08:05mysql slow query 설정

영구적적용 my.cnf 위치확인 [darksharavim]mysql --verbose --help | grep 'my.cnf' /etc/my.cnf ~/.my.cnf my.cnf설정 [mysqld] # slow query on = 1, slow query off = 0 slow_query_log = 1 # n초이상 걸렷을 경우 query_long_time = 5 # file이 아닌 table도 가능하며 # table로 할 경우 logfile경로 옵션 주석처리 log_output = file # defualt name = host_name-slow.log slow_query_log_file = /var/log/mysql/slowquery.log mysql service restart 한시적 적용 sessi..

image