2016년 5월 6일 금요일
에버노트에서 원노트로 데이터 옮겨오기
에버노트를 무료로 이용하려면 한달에 업로드 할 수 있는 용량이 60M 밖에 되지 않습니다.
원노트도 에버노트만큼 기능이 개선되었고 무엇보다도 무료로 사용 할 수 있고 용량의 제약이 없어서 최근에는 업무 및 정보 수집 용도로 에버노트를 이용중입니다.
에버노트의 강력한 글 수집 기능을 이용하기위하여 에버노트로 사용하고 그 글을 복사 하여
원노트에다 갖다 붙입니다.
그리고
에버노트에서 원노트 로 옮기고 싶으신 분들은 무료 임포팅 툴을 사용해보세요
https://www.onenote.com/import-evernote-to-onenote
[참고 URL] 영문 사이트
https://t.co/nX18pjpL3g
2011년 6월 23일 목요일
[MYSQL]ON DUPLICATE KEY UPDATE
중복 발생시 카운트 올리기
INSERT INTO log (name, location, counter)
-> VALUES ('Tantor', 'Waterhole', 1)
-> ON DUPLICATE KEY UPDATE counter=counter+1;
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM log;
+--------+-----------+---------+
| name | location | counter |
+--------+-----------+---------+
| Tantor | Waterhole | 1 |
+--------+-----------+---------+
1 row in set (0.00 sec)
mysql> INSERT INTO log (name, location, counter)
-> VALUES ('Tantor', 'Waterhole', 1)
-> ON DUPLICATE KEY UPDATE counter=counter+1;
Query OK, 2 rows affected (0.00 sec)
2010년 12월 14일 화요일
[MySQL]필드에 서브쿼리를 사용한경우 서브쿼리 값을 WHERE절에서 검색 하는 방법
s.id as shop_id ,
s.hq_name as hq_name ,
i.work_date as work_date ,
( SELECT n.`count` FROM work_order.inv_new as n
AND n.shop_id = i.shop_id
) as cnt1,
( SELECT n.`count` FROM work_order.inv_new as n
AND n.shop_id = i.shop_id
) as cnt2
FROM `work_order`.`shop` as s
WHERE cnt1 = '1'
이면 에러가 난다. 앨리어스는 검색 할수 없더라.
하다가 안되어서 FROM 절에 SELECT 쓰는 것으로 INLINE VIEW 라고 하더라.
MySQL에서도 되는 듯 하여 써봤다.
SELECT 문을 그대로 두고 필드에 일일이 앨리어스를 붙인다음 ( ) 로 싸고 그 앨리어스를
필드명으로 설정 하여 출력 했다.
SELECT shop_id,
hq_name,
shop_name,
place,
agency_cd,
work_date,
FROM
( SELECT
s.id as shop_id ,
s.hq_name as hq_name ,
s.shop_name as shop_name ,
s.place as place ,
s.agency_cd as agency_cd ,
i.work_date as work_date ,
( SELECT n.`count` FROM work_order.inv_new as n
AND n.shop_id = i.shop_id
) as cnt1,
( SELECT n.`count` FROM work_order.inv_new as n
AND n.shop_id = i.shop_id
) as cnt2
FROM `work_order`.`shop` as s
) as l
WHERE cnt1 != cnt2 or cnt1 = 10
2010년 11월 18일 목요일
MySQL 테이블 체크 및 자동 복구
자체적으로 만든 스크립트를 이용해서 테이블별로 백업을 하면서 테이블 체크를 하는데
mysqlcheck 란 실행 화일을 cron에다 등록 시켜서 해도 상관 없겠다.
$backup_db = array("db1","db2")
$optimize =1;
foreach($backup_db AS $dbName)
{
echo "\n========== $dbName ==========\n";
// DB
$cmd="mysql -uroot -p".DB_PW." $dbName -e\"show tables\" ";
exec($cmd,$tableArr);
// 테이블
foreach($tableArr As $val)
{
if(strstr($val,"+")) continue;
if(strstr($val,"Tables_in_".$dbName)) continue;
if(ereg("([a-zA-Z0-9_])+",$val,$regs))
{
$tableName=trim($regs[0]);
}
else
continue;
// 필요 없는 건 걸러내고 테이블 이름만 취한다.
if($optimize)
{
$opt_exe = "mysql -uroot -p".DB_PW." $dbName -e\"optimize table device.$tableName\" ";
exec($opt_exe,$output);
}
$dateYMD= date("Y-m-d");
$last_line=system("mysqldump -uroot -p".DB_PW." --extended-insert=FALSE --add-drop-table --create-options --disable-keys --add-locks --skip-opt --no-create-db --default-character-set=euckr --set-charset -n -t \"$dbName\" $tableName > $backupDir/$dateYMD/{$tableName}.sql");
} //전체루프
mysql -uroot -p암호 -e"optimize table tablename" 이런식으로 테이블 최적화 하고 php 스크립트를 cron에다 등록 시켜 놓는다.
다음과 같이 유틸리티를 써서 하는게 편하겠다.
으로 하면 2시에 인덱스 복구, 최적화,분석 까지 --auto-repair 면 잘못 된 테이블 복구 까지 자동으로 해준다.
MySQL DB 백업 및 일자별 압축 한방에..
/data/backup/dbbackup_YYYY-MM-DD.dump.bz2 형식으로 파일이 만들어져서 쌓이게 됩니다.
mysqldump 로 나온 텍스트 데이타를 파이프를 이용해서 흘러나온 데이타를 bzip에서 바로 압축 하는 것입니다.
파이프 뒤에 tar 나 기타 압축 도구를 사용해도 되며 mail 을 사용해서 전송 할수도 있습니다.
2010년 11월 17일 수요일
그림주위의 채워진 글
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
</HEAD>
<style>
</style>
<script>
$(document).ready(function() {
$('.feature1').css({'width':'50%', 'border':'1px dashed', 'float':'left'});
});
</script>
<body>
<img src='dddd' alt='그림'> <class="feature1">123456778891234567788912345677889123456778891234567788912345677889123456778891234567788912345677889123456778891234567788912345677889123456778891234567788912345677889123456778891234567788912345677889 </p>
</body>
</HTML>
2010년 10월 30일 토요일
Word에서 작업 파일을 만들 수 없습니다. 오류해결법
증상#
프로그램을 실행하거나, 사용하는 도중에 다음과 같은 메시지가 다이얼로그 창으로 나타난다.
Word에서 작업 파일을 만들 수 없습니다. 임시 환경 변수를 확인하십시오
원인#
임시 인터넷 파일의의 주소가 잘못 지정되어있는 경우 발생한다. 임시 인터넷 파일 저장하는 폴더를 따로 설정했거나, 드라이브 재설치나 변경 등으로 문제가 발생할 수 있다.
해결책#
실행에서 regedit를 실행시킨다.
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders 로 이동한다.
이 곳에 있는 값 중에서 Cache 값은 임시 인터넷 파일 경로임을 알 수 있다. 잘못된 임시 인터넷 파일 경로를 올바른 경로로 수정해주면 문제가 해결된다.
2010년 8월 24일 화요일
IFRAME 내부의 문서의 높이에 따라서 IFRAME높이를 자동조정
scrollHeight 의 사용
<IFRAME name="mainFrame" src="document.html"></IFRAME>
document.html
<html>
<SCRIPT>
window.onload = function() {
var sH=document.body.scrollHeight;
parent.document.getElementById("mainFrame").style.height=sH+40;
}
</SCRIPT>
<body>
내용이 많아서 스크롤 바가 생긴다. 그런데 스크롤 생기는 건 싫다.
문서가 로딩 땔때 scrollHeight; 를 구해서 숫자를 조금 더해 준후 상위 프레임의
document.... 에서 mainframe 의 스타일 속성을 자동으로 설정 한다.
</body>
</html>
2010년 5월 18일 화요일
MySQL의 데이터를 백업
MySQL의 데이터를 백업하는 방법은 크게 두가지로 분류 할 수 있다.
1. mysqldump를 이용한 text타입의 백업 방법.
2. 데이터파일 자체를 복사하는 백업 방법.
두가지 방법모두 장단점이 있으므로 용도와 필요에 맞게 사용하는 것이 좋다.
1. mysqldump를 이용한 백업(출처 : http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html)
mysqldump는 Igor Romanenko라는 사람이 만든 백업 프로그램이다. 이는 database나 database의 일부를 백업하는 목적이나 다른 시스템으로 옮길때 사용된다. 그리고 원하는 분리 문자를 넣을 수 있어 CSV파일 등으로 만들 수 있으며, XML포맷으로 만들 수도 있다.
굉장히 많은 옵션들을 제공하고 있는 만큼 사용하는 방법과 용도 또한 여러가지이다. 먼저 가장 기본적인 사용법 부터 알아 보자. 아래에 옵션표를 첨부할 것이다.
1) database백업
shell> mysqldump -u comnic -p database1 > database1_20090321000000.sql
위는 comnic이라는 유저로 database1이라는 database를 database1_20090321000000.sql파일로 백업하라는 내용이다.
2) table백업
shell> mysqldump -u comnic -p database1 table1 > table1_20090321000000.sql
위는 comnic이라는 유저로 database1의 table1이라는 table을 table1_20090321000000.sql파일로 백업하라는 내용이다.
3) Table 구조만 백업
shell> mysqldump --no-data -u comnic -p database1 > 20090321000000.sql
위는 comnic이라는 유저로 database1의 table구조를 20090321000000.sql파일로 백업하라는 내용이다.
--no-data 옵션은 create table문장만을 백업하기를 원할때 유용한다.
4) Table별로 백업 파일 생성
shell> mysqldump -u comnic -p --tab=/backup database1
/backup이라는 폴더에 table마다 각각 tbl_name.sql파일과 tbl_name.txt파일을 생성한다. 이는 Table의 구조와 데이터를 분리 하여 백업하는 것을 의미 한다. .sql파일은 구조를 .txt파일은 데이터를 저장한다. 이때 분리 문자가 사용되는데 기본적을 tab이 사용된다. 이 분리문자를 변경하면 원하는 분리 문자로 구성된 파일을 만들 수 있다.
5) CSV파일로 백업 및 다른 분리 문자로 백업
shell> mysqldump -u comnic -p --tab=/backup --fields-terminated-by=',' database1
기본적인 분리문자인 tab대신 ,를 사용해 백업을 한다. 즉, CSV파일로 생성된다.
6) XML포맷으로 백업
shell> mysqldump -u comnic -p --xml database1 > 20090321000000.xml
2. 복구하기
위와 같은 방법들로 백업된 파일을 복구하는 방법은 아래와 같다.
shell> mysql -u comnic -p database1 < 20090321000000.sql
복구시 한글이 깨지는 경우가 종종 있다. 그럴때는 아래와 같이 --default-character-set 옵션을 사용해 복구한다.
3. 바이너리 백업(파일 복사 혹은 압축을 이용)
MySQL을 사용하는 사용자들은 흔히 data파일을 복사하는 방식의 백업이 쉽고 빠르다고 얘기들을 한다. 나 또한 그런식으로 백업을 많이 하고 있다. shell 프로그램으로 자동 백업 후 다른 시스템으로 ftp를 이용해 옮기는 방법으로 자동화를 많이 사용 하고 있다. shell를 이용한 자동화 부분은 다음에 다루도록 하겠다.
1) 복사 및 압축을 이용한 백업
cp와 tar를 이용하면 쉽게 백업을 할 수 있다. 복사전에 lock을 걸어주고 복사가 끝난후 unlock를 꼭 해 주어야 한다.
복구는 파일 그냥 다시 복사 해 주면 된다. 데이터를 옮기는 과정이라면 복사 이후 추가된 데이터를 다시 추가 해 주어야 한다.
2) mysqlhotcopy를 이용한 백업(출처:http://dev.mysql.com/doc/refman/5.1/en/mysqlhotcopy.html)
DB전체를 백업할때는 mysqldump보다 이를 이용하면 더욱 빠르게 백업을 할 수 있다고 한다.
mysqlhotcopy는 LOCK TABLES, FLUSH TABLES 그리고 cp나 scp를 이용해 파일을 생성한다.
주의 할점은
MyISAM과 ARCHIVE table만 가능하다는 것이다.사용방법은 다은과 같다.
shell> mysqlhotcopy db_name_1 ... db_name_n /path/to/new_directory
정규식을 이용하는 방법도 있다.
shell> mysqlhotcopy db_name./~regex/
첨부.1
| Format | Config File | Description | Introduction |
|---|---|---|---|
| --add-drop-database | add-drop-database | Add a DROP DATABASE statement before each CREATE DATABASE statement | |
| --add-drop-table | add-drop-table | Add a DROP TABLE statement before each CREATE TABLE statement | |
| --add-locks | add-locks | Surround each table dump with LOCK TABLES and UNLOCK TABLES statements | |
| --all-databases | all-databases | Dump all tables in all databases | |
| --all-tablespaces | all-tablespaces | Adds to a table dump all SQL statements needed to create any tablespaces used by an NDB Cluster table | 5.1.6 |
| --allow-keywords | allow-keywords | Allow creation of column names that are keywords | |
| --comments | comments | Add comments to the dump file | |
| --compact | compact | Produce less verbose output | |
| --compatible=name[,name,...] | compatible | Produce output that is more compatible with other database systems or with older MySQL servers | |
| --complete-insert | complete-insert | Use complete INSERT statements that include column names | |
| --create-options | create-options | Include all MySQL-specific table options in the CREATE TABLE statements | |
| --databases | databases | Dump several databases | |
| --debug[=debug_options] | debug | Write a debugging log | |
| --debug-check | debug-check | Print debugging information when the program exits | 5.1.21 |
| --debug-info | debug-info | Print debugging information, memory and CPU statistics when the program exits | 5.1.14 |
| --delayed-insert | delayed-insert | Write INSERT DELAYED statements rather than INSERT statements | |
| --delete-master-logs | delete-master-logs | On a master replication server, delete the binary logs after performing the dump operation | |
| --disable-keys | disable-keys | For each table, surround the INSERT statements with disable and enable keys statements | |
| --dump-date | dump-date | Include dump date in "Dump completed on" comment if --comments is given | 5.1.23 |
| -E | events | Dump events from the dumped databases | |
| --extended-insert | extended-insert | Use multiple-row INSERT syntax that include several VALUES lists | |
| --fields-enclosed-by=string | fields-enclosed-by | This option is used with the -T option and has the same meaning as the corresponding clause for LOAD DATA INFILE | |
| --fields-escaped-by | fields-escaped-by | This option is used with the -T option and has the same meaning as the corresponding clause for LOAD DATA INFILE | |
| --fields-optionally-enclosed-by=string | fields-optionally-enclosed-by | This option is used with the -T option and has the same meaning as the corresponding clause for LOAD DATA INFILE | |
| --fields-terminated-by=string | fields-terminated-by | This option is used with the -T option and has the same meaning as the corresponding clause for LOAD DATA INFILE | |
| --lock-all-tables | first-slave | Deprecated. Now renamed to --lock-all-tables | |
| --flush-logs | flush-logs | Flush the MySQL server log files before starting the dump | |
| --flush-privileges | flush-privileges | Emit a FLUSH PRIVILEGES statement after dumping the mysql database | |
| --help | Display help message and exit | ||
| --hex-blob | hex-blob | Dump binary columns using hexadecimal notation (for example, 'abc' becomes 0x616263) | |
| --ignore-table=db_name.tbl_name | ignore-table | Do not dump the given table | |
| --insert-ignore | insert-ignore | Write INSERT statements with the IGNORE option | |
| --lines-terminated-by=string | lines-terminated-by | This option is used with the -T option and has the same meaning as the corresponding clause for LOAD DATA INFILE | |
| --lock-all-tables | lock-all-tables | Lock all tables across all databases | |
| --lock-tables | lock-tables | Lock all tables before dumping them | |
| --log-error=file_name | log-error | Append warnings and errors to the named file | 5.1.18 |
| --master-data[=value] | master-data | Write the binary log file name and position to the output | |
| --max_allowed_packet=value | max_allowed_packet | The maximum packet length to send to or receive from the server | |
| --net_buffer_length=value | net_buffer_length | The buffer size for TCP/IP and socket communication | |
| --no-autocommit | no-autocommit | Enclose the INSERT statements for each dumped table within SET autocommit = 0 and COMMIT statements | |
| --no-create-db | no-create-db | This option suppresses the CREATE DATABASE statements | |
| --no-create-info | no-create-info | Do not write CREATE TABLE statements that re-create each dumped table | |
| --no-data | no-data | Do not write any table row information (that is, do not dump table contents) | |
| --no-set-names | no-set-names | Turn off complete-insert | |
| --opt | opt | This option is shorthand; it is the same as specifying --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset. | |
| --order-by-primary | order-by-primary | Sorts each table's rows by its primary key, or by its first unique index | |
| --password[=password] | password | The password to use when connecting to the server | |
| --pipe | On Windows, connect to server via a named pipe | ||
| --port=port_num | port | The TCP/IP port number to use for the connection | |
| --quick | quick | Retrieve rows for a table from the server a row at a time | |
| --quote-names | quote-names | Quote database, table, and column names within backtick characters | |
| --replace | replace | Write REPLACE statements rather than INSERT statements | |
| --result-file=file | result-file | Direct output to a given file | |
| -R | routines | Dump stored routines (procedures and functions) from the dumped databases | |
| --set-charset | set-charset | Add SET NAMES default_character_set to the output | |
| --single-transaction | single-transaction | This option issues a BEGIN SQL statement before dumping data from the server | |
| --skip-add-drop-table | skip-add-drop-table | Do not add | |
| --skip-add-locks | skip-add-locks | Do not add locks | |
| --skip-comments | skip-comments | Do not add comments to the dump file | |
| --skip-compact | skip-compact | Turn off compact | |
| --skip-disable-keys | skip-disable-keys | Do not disable keys | |
| --skip-extended-insert | skip-extended-insert | Turn off extended-insert | |
| --skip-opt | skip-opt | Turn off the options set by opt | |
| --skip-quick | skip-quick | Do not retrieve rows for a table from the server a row at a time | |
| --skip-quote-names | skip-quote-names | Turn off quote names | |
| --skip-set-charset | skip-set-charset | Suppress the SET NAMES statement | |
| --skip-triggers | skip-triggers | Turn off triggers | |
| --skip-tz-utc | skip-tz-utc | Turn off tz-utc | |
| --ssl-ca=file_name | ssl-ca | The path to a file that contains a list of trusted SSL CAs | |
| --ssl-capath=directory_name | ssl-capath | The path to a directory that contains trusted SSL CA certificates in PEM format | |
| --ssl-cert=file_name | ssl-cert | The name of the SSL certificate file to use for establishing a secure connection | |
| --ssl-cipher=cipher_list | ssl-cipher | A list of allowable ciphers to use for SSL encryption | |
| --ssl-key=file_name | ssl-key | The name of the SSL key file to use for establishing a secure connection | |
| --ssl-verify-server-cert | ssl-verify-server-cert | The server's Common Name value in its certificate is verified against the host name used when connecting to the server | |
| --tab=path | tab | Produce tab-separated data files | |
| --tables | tables | Override the --databases or -B option | |
| --triggers | triggers | Dump triggers for each dumped table | |
| --tz-utc | tz-utc | Add SET TIME_ZONE='+00:00' to the dump file | |
| --verbose | Verbose mode | ||
| --version | Display version information and exit | ||
| --where='where_condition' | where | Dump only rows selected by the given WHERE condition | |
| --xml | xml | Produce XML output |
에버노트에서 원노트로 데이터 옮겨오기
에버노트를 무료로 이용하려면 한달에 업로드 할 수 있는 용량이 60M 밖에 되지 않습니다. 원노트도 에버노트만큼 기능이 개선되었고 무엇보다도 무료로 사용 할 수 있고 용량의 제약이 없어서 최근에는 업무 및 정보 수집 용도로 에버노트를 이용중입니다...
-
chromeos-image-999.999.32309.211410-a1.vmdk.bz2.5170843..torrent http://thepiratebay.org/torrent/5170843 크롬 OS가 나왔길래 한번 깔아 봤다. ...
-
윈도우에서 갑자기 플래시 사운드가 들리지 않을때 오늘 갑자기 윈도우7 에서 플래시 사운드 및 시스템 사운드가 들리지 않길래 이리해도 저리해도 안되어서 유틸리티를 찾아 봤더니 Windows Manager 에서 Repair Center ...
-
SELECT s.id as shop_id , s.hq_name as hq_name , i.work_date as work_date , ( SELEC...