SELECT 
concat(table_schema,'.',table_name), 
concat(round(table_rows/1000000,2),'M') rows, 
concat(round(data_length/(1024*1024*1024),2),'G') DATA, 
concat(round(index_length/(1024*1024*1024),2),'G') idx, 
concat(round((data_length+index_length)/(1024*1024*1024),2),'G') total_size, 
round(index_length/data_length,2) idxfrac 
FROM information_schema.TABLES
where table_schema='데이터베이스명'
order by data desc;




블로그 이미지

엘로드넷

,

특정 파일 열지 않고 인코딩 변환


#iconv -f 원래인코딩 -t 변경할인코딩 파일명




euckr 에서 utf8로 변경할 경우 : 


#iconv -f cp949 -t utf8 파일명



'Linux' 카테고리의 다른 글

CentOS7 sshd 포트 변경하기  (0) 2017.10.29
아파치 OpenSSL 사설인증서 적용  (0) 2016.12.06
텍스트파일 텍스트 치환  (0) 2016.12.06
리눅스 버전 확인 Linux version check  (0) 2016.12.05
Centos 배포판 구분  (0) 2016.10.21
블로그 이미지

엘로드넷

,

텍스트 파일을 열지 않고 내부 특정 텍스트 치환


#sed 's/찾을문자열/바꿀문자열/g' 텍스트파일명




블로그 이미지

엘로드넷

,

SQL Server

select @@version;



MySQL/Mariadb

select version();



Oracle

select * from v$version;



블로그 이미지

엘로드넷

,

grap . /etc/*-release


[root@localhost etc]# grep . /etc/*-release

/etc/centos-release:CentOS Linux release 7.2.1511 (Core) 

/etc/os-release:NAME="CentOS Linux"

/etc/os-release:VERSION="7 (Core)"

/etc/os-release:ID="centos"

/etc/os-release:ID_LIKE="rhel fedora"

/etc/os-release:VERSION_ID="7"

/etc/os-release:PRETTY_NAME="CentOS Linux 7 (Core)"

/etc/os-release:ANSI_COLOR="0;31"

/etc/os-release:CPE_NAME="cpe:/o:centos:centos:7"

/etc/os-release:HOME_URL="https://www.centos.org/"

/etc/os-release:BUG_REPORT_URL="https://bugs.centos.org/"

/etc/os-release:CENTOS_MANTISBT_PROJECT="CentOS-7"

/etc/os-release:CENTOS_MANTISBT_PROJECT_VERSION="7"

/etc/os-release:REDHAT_SUPPORT_PRODUCT="centos"

/etc/os-release:REDHAT_SUPPORT_PRODUCT_VERSION="7"

/etc/redhat-release:CentOS Linux release 7.2.1511 (Core) 

/etc/system-release:CentOS Linux release 7.2.1511 (Core) 

[root@localhost etc]# 






블로그 이미지

엘로드넷

,

1. 디비툴이 있다면 쿼리편집기에서 아래 명령어를 쿼리날린다.



  SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') 

  FROM INFORMATION_SCHEMA.TABLES 

  WHERE TABLE_NAME LIKE 'prefix_테이블명%' 

  AND TABLE_SCHEMA = '데이터베이스명';



테이블이 많다면 아래와 같이 결과가 나온다.


DROP TABLE 데이터베이스명.prefix_테이블명xx ;

DROP TABLE 데이터베이스명.prefix_테이블명xx ;

DROP TABLE 데이터베이스명.prefix_테이블명xx ;

DROP TABLE 데이터베이스명.prefix_테이블명xx ;

DROP TABLE 데이터베이스명.prefix_테이블명xx ;



검색결과를 복사해서 다시한번 쿼리 편집기에 넣어 쿼리를 날린다.





2. 쿼리결과를 파일로 저장해야할 경우


SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') 

FROM INFORMATION_SCHEMA.TABLES 

WHERE TABLE_NAME LIKE 'prefix_테이블명%' 

AND TABLE_SCHEMA = '데이터베이스명' 

INTO OUTFILE '/tmp/저장할파일명.sql';



아래와 같이,

MariaDB [mysql]> SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') 

    -> FROM INFORMATION_SCHEMA.TABLES 

    -> WHERE TABLE_NAME LIKE 'prefix_테이블명%' 

    -> AND TABLE_SCHEMA = '테이터베이스명' 

    -> INTO OUTFILE '/tmp/저장할파일명.sql';



그 후,


MariaDB [mysql]> source /tmp/저장할파일명.sql



삭제가 될 것이다.



'MySQL, MariaDB' 카테고리의 다른 글

CentOS7 nginx, mariadb10, php-fpm 설치  (0) 2017.01.05
MySQL/Mariadb 테이블 사이즈 확인  (0) 2016.12.06
MAMP mysql upgrade to 5.7.16 osx  (0) 2016.11.17
MySQL CAST  (0) 2016.05.12
특정 테이블 데이터 백업 및 복구  (0) 2016.03.19
블로그 이미지

엘로드넷

,

Open Active Scan Options as below





Go to Passive Scan Rules section.


Private IP Disclosure set to OFF






블로그 이미지

엘로드넷

,

1. upgrade 스크립트 파일을 만든다.



ELLORDNET-MPR:~ ellord$ vi upgrademysql.sh



#!/bin/sh


wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-osx10.11-x86_64.tar.gz

tar xfvz mysql-5.7.16-osx10.11-x86_64.tar.gz



echo "stopping mamp"

sudo /Applications/MAMP/bin/stop.sh

sudo killall httpd mysqld


echo "creating backup"

sudo rsync -arv --progress /Applications/MAMP ~/Desktop/MAMP-Backup


echo "copy bin"

sudo rsync -arv --progress mysql-5.7.*/bin/* /Applications/MAMP/Library/bin/ --exclude=mysqld_multi --exclude=mysqld_safe


echo "copy share"

sudo rsync -arv --progress mysql-5.7.*/share/* /Applications/MAMP/Library/share/


echo "fixing access (workaround)"

sudo chmod -R o+rw  /Applications/MAMP/db/mysql/

sudo chmod -R o+rw  /Applications/MAMP/tmp/mysql/


echo "starting mamp"

sudo /Applications/MAMP/bin/start.sh


echo "migrate to new version"

sudo chmod -R 777 /Applications/MAMP/db/mysql/

/Applications/MAMP/Library/bin/mysql_upgrade --user=root --password=root --host=localhost --port=3306



2. 스크립트를 실행한다.


ELLORDNET-MPR:~ ellord$ ./upgrademysql.sh



-2016-11-17 10:22:55--  http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-osx10.11-x86_64.tar.gz

Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11

Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.

HTTP request sent, awaiting response... 302 Found

Location: http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.16-osx10.11-x86_64.tar.gz [following]

--2016-11-17 10:22:56--  http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.16-osx10.11-x86_64.tar.gz

Resolving cdn.mysql.com (cdn.mysql.com)... 104.76.99.248

Connecting to cdn.mysql.com (cdn.mysql.com)|104.76.99.248|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 331502302 (316M) [application/x-tar-gz]

Saving to: ‘mysql-5.7.16-osx10.11-x86_64.tar.gz.2’


 9% [========>                                                                                        ] 32,386,761  4.60MB/s  eta 64s    



아래와 같이 비밀번호를 입력하라고 하면.


stopping mamp

Password:



맥의 비밀번호를 입력해 준다.




마지막에 아래와 같은 에러가 나면.


migrate to new version

chmod: /Applications/MAMP/db/mysql/: No such file or directory

mysql_upgrade: [Warning] Using a password on the command line interface can be insecure.

mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) while connecting to the MySQL server

Upgrade process encountered error and will not continue.

ELLORDNET-MPR:Documents ellord$ 161117 10:24:48 mysqld_safe Starting mysqld daemon with databases from /Applications/MAMP/db/mysql56

161117 10:24:49 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended



mysql_upgrade 명령을 수동으로 실행한다.


ELLORDNET-MPR:bin ellord$ cd /Application/MAMP/Library/bin

ELLORDNET-MPR:bin ellord$ ./mysql_upgrade -u root 

mysql_upgrade: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) while connecting to the MySQL server

Upgrade process encountered error and will not continue.

ELLORDNET-MPR:bin ellord$ ./mysql_upgrade -u root --password=didckswn

mysql_upgrade: [Warning] Using a password on the command line interface can be insecure.

Checking if update is needed.

Checking server version.

Running queries to upgrade MySQL server.

mysql_upgrade: [ERROR] 1146: Table 'mysql.innodb_table_stats' doesn't exist



그래도 에러가 난다면.



mysql 접속.


ELLORDNET-MPR:bin ellord$ ./mysql -u root -p mysql

Enter password: 



아래 5개 테이블 삭제.


innodb_index_stats
innodb_table_stats
slave_master_info
slave_relay_log_info
slave_worker_info


mysql> show tables;

+---------------------------+

| Tables_in_mysql           |

+---------------------------+

| columns_priv              |

| db                        |

| engine_cost               |

| event                     |

| func                      |

| general_log               |

| gtid_executed             |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| innodb_index_stats        |

| innodb_table_stats        |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| proxies_priv              |

| server_cost               |

| servers                   |

| slave_master_info         |

| slave_relay_log_info      |

| slave_worker_info         |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

+---------------------------+

31 rows in set (0.01 sec)


mysql> drop table innodb_index_stats;



아래 5개 파일도 삭제.

innodb_index_stats.ibd
innodb_table_stats.ibd
slave_master_info.ibd
slave_relay_log_info.ibd
slave_worker_info.ibd

ELLORDNET-MPR:mysql ellord$ pwd

/Applications/MAMP/db/mysql56/mysql

ELLORDNET-MPR:mysql ellord$ rm -rf innodb_index_stats.ibd



5개 테이블 새로 만듬.


mysql> 


CREATE TABLE `innodb_index_stats` (

  `database_name` varchar(64) COLLATE utf8_bin NOT NULL,

  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,

  `index_name` varchar(64) COLLATE utf8_bin NOT NULL,

  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

  `stat_name` varchar(64) COLLATE utf8_bin NOT NULL,

  `stat_value` bigint(20) unsigned NOT NULL,

  `sample_size` bigint(20) unsigned DEFAULT NULL,

  `stat_description` varchar(1024) COLLATE utf8_bin NOT NULL,

  PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;


CREATE TABLE `innodb_table_stats` (

  `database_name` varchar(64) COLLATE utf8_bin NOT NULL,

  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,

  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

  `n_rows` bigint(20) unsigned NOT NULL,

  `clustered_index_size` bigint(20) unsigned NOT NULL,

  `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,

  PRIMARY KEY (`database_name`,`table_name`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;


CREATE TABLE `slave_master_info` (

  `Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.',

  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log currently being read from the master.',

  `Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last read event.',

  `Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.',

  `User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',

  `User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',

  `Port` int(10) unsigned NOT NULL COMMENT 'The network port used to connect to the master.',

  `Connect_retry` int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',

  `Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.',

  `Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',

  `Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',

  `Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',

  `Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',

  `Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',

  `Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.',

  `Heartbeat` float NOT NULL,

  `Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',

  `Ignored_server_ids` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs',

  `Uuid` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',

  `Retry_count` bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.',

  `Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',

  `Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',

  `Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',

  PRIMARY KEY (`Host`,`Port`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';


CREATE TABLE `slave_relay_log_info` (

  `Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file or rows in the table. Used to version table definitions.',

  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the current relay log file.',

  `Relay_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The relay log position of the last executed event.',

  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log file from which the events in the relay log file were read.',

  `Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last executed event.',

  `Sql_delay` int(11) NOT NULL COMMENT 'The number of seconds that the slave must lag behind the master.',

  `Number_of_workers` int(10) unsigned NOT NULL,

  `Id` int(10) unsigned NOT NULL COMMENT 'Internal Id that uniquely identifies this record.',

  PRIMARY KEY (`Id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Relay Log Information';


CREATE TABLE `slave_worker_info` (

  `Id` int(10) unsigned NOT NULL,

  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,

  `Relay_log_pos` bigint(20) unsigned NOT NULL,

  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,

  `Master_log_pos` bigint(20) unsigned NOT NULL,

  `Checkpoint_relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,

  `Checkpoint_relay_log_pos` bigint(20) unsigned NOT NULL,

  `Checkpoint_master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,

  `Checkpoint_master_log_pos` bigint(20) unsigned NOT NULL,

  `Checkpoint_seqno` int(10) unsigned NOT NULL,

  `Checkpoint_group_size` int(10) unsigned NOT NULL,

  `Checkpoint_group_bitmap` blob NOT NULL,

  PRIMARY KEY (`Id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Worker Information';






이제 다시 mysql_upgrade 를 시도해 본다.


ELLORDNET-MPR:bin ellord$ ./mysql_upgrade --user=root --password

Enter password:

mysql_upgrade: [Warning] Using a password on the command line interface can be insecure.

Checking if update is needed.

Checking server version.

Running queries to upgrade MySQL server.

Checking system database.

mysql.columns_priv                                 OK

mysql.db                                           OK

mysql.engine_cost                                  OK

mysql.event                                        OK

mysql.func                                         OK

mysql.general_log                                  OK

mysql.gtid_executed                                OK


sys.sys_config                                     OK

Upgrade process completed successfully.

Checking if update is needed.



위와 같이 정상적으로 업그레이드 되었다.


접속해 본다.

ELLORDNET-MPR:bin ellord$ ./mysql -u root -p mysql

Enter password: 

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.7.16 MySQL Community Server (GPL)


Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> 

mysql> select @@version;

+-----------+

| @@version |

+-----------+

| 5.7.16    |

+-----------+

1 row in set (0.00 sec)


mysql> 




5.7.16 으로 업데이트 되었다.

















블로그 이미지

엘로드넷

,

이클립스 mars, neon 기준


Help > Install New Software


Work With : http://community.polarion.com/projects/subversive/download/eclipse/4.0/mars-site




블로그 이미지

엘로드넷

,

아래 그림처럼 jquery timepicker 를 이용하여 시간 select 하기.






1. 필요한 파일



jquery.timepicker.css

jquery.timepicker.min.js



다운로드 : 

jquery-timepicker.zip



두 파일을 적당한 곳에 올리고 timepicker를 적용할 파일에 인클루드 한다.




<input type="text" name="time1" value="" placeholder="시간선택"  id="time1" required size="8" maxlength="5">



2. 


$("#time1").timepicker({

step: 5,            //시간간격 : 5분

timeFormat: "H:i"    //시간:분 으로표시

});



기타 timeFormat 옵션


H : 24시간제로 표시

h : 12시간제로 표시

i : 분

s : 초

A : AM/PM표시



H:i:s : 24시간:분:초 로 표시

H:i A : 24시간:분 AM으로 표시



페이지 로딩시 현재시간 자동으로 입력.


$(document).ready(function(){

$("#time1").timepicker('setTime', new Date());

});




기타 자세한 내용은 아래 링크에서 확인


https://github.com/jonthornton/jquery-timepicker






끝.


블로그 이미지

엘로드넷

,