Sep 042012
 

MySQL에서 사용하는 패스워드로 사용할 수 있는 함수를 버전별로 테스트한 결과입니다.

프로그램을 시작할때 참고를 해서 테스트를 해보시면 좋습니다.

비밀번호를 md5()를 한 다음에 sha1()을 처리하고, 나머지 데이타는 encode() 혹은 des_encrypt()를 내부 암호키를 이용해서 저장하고 관리하는 방법을 사용하면 효과적입니다.

[smlee@A ~]$ mysql -p -u root
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 644167
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select password('dltjrans');
+----------------------+
| password('dltjrans') |
+----------------------+
| 337c52a05f635196     |
+----------------------+
1 row in set (0.03 sec)

mysql> select sha1('dltjrans');
+------------------------------------------+
| sha1('dltjrans')                         |
+------------------------------------------+
| 2734580af3645aae53a80ce3a60841636e4f5f16 |
+------------------------------------------+
1 row in set (0.02 sec)

mysql> select sha2('dltjrans');
ERROR 1305 (42000): FUNCTION sha2 does not exist

mysql> select encrypt('dltjrans');
+---------------------+
| encrypt('dltjrans') |
+---------------------+
| iBlePNVyWUPF2       |
+---------------------+
1 row in set (0.00 sec)

mysql> select md5('dltjrans');
+----------------------------------+
| md5('dltjrans')                  |
+----------------------------------+
| 44022b75cd0626a239a1c0ec42e0b902 |
+----------------------------------+
1 row in set (0.00 sec)

mysql> select old_password('dltjrans');
+--------------------------+
| old_password('dltjrans') |
+--------------------------+
| 337c52a05f635196         |
+--------------------------+
1 row in set (0.00 sec)

mysql> show variables;
+---------------------------------+------------------------------------------------------------+
| Variable_name                   | Value                                                      |
+---------------------------------+------------------------------------------------------------+
......
| old_passwords                   | ON                                                         |
......
+---------------------------------+------------------------------------------------------------+
239 rows in set (0.01 sec)

[smlee@B ~]$ /usr/local/mysql/bin/mysql --character-sets-dir=utf8  -p -u root
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 326943
Server version: 5.1.58-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

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

mysql> select password('dltjrans');
+-------------------------------------------+
| password('dltjrans')                      |
+-------------------------------------------+
| *8FE4DE9DB3E99B3D33C46101724499112B4E08C0 |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> select sha('dltjrans');
+------------------------------------------+
| sha('dltjrans')                          |
+------------------------------------------+
| 2734580af3645aae53a80ce3a60841636e4f5f16 |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> select sha1('dltjrans');
+------------------------------------------+
| sha1('dltjrans')                         |
+------------------------------------------+
| 2734580af3645aae53a80ce3a60841636e4f5f16 |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> select encrypt('dltjrans');
+---------------------+
| encrypt('dltjrans') |
+---------------------+
| dZew2kBw.Cajg       |
+---------------------+
1 row in set (0.00 sec)

mysql> select old_password('dltjrans');
+--------------------------+
| old_password('dltjrans') |
+--------------------------+
| 337c52a05f635196         |
+--------------------------+
1 row in set (0.00 sec)

[smlee@C ~]$ mysql -p -u root
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 33751
Server version: 5.5.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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> select password('dltjrans');
+-------------------------------------------+
| password('dltjrans')                      |
+-------------------------------------------+
| *8FE4DE9DB3E99B3D33C46101724499112B4E08C0 |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> select sha('dltjrans');
+------------------------------------------+
| sha('dltjrans')                          |
+------------------------------------------+
| 2734580af3645aae53a80ce3a60841636e4f5f16 |
+------------------------------------------+
1 row in set (0.03 sec)

mysql> select sha1('dltjrans');
+------------------------------------------+
| sha1('dltjrans')                         |
+------------------------------------------+
| 2734580af3645aae53a80ce3a60841636e4f5f16 |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> select encrypt('dltjrans');
+---------------------+
| encrypt('dltjrans') |
+---------------------+
| yb/DPswDxmSnk       |
+---------------------+
1 row in set (0.00 sec)

mysql> select old_password('dltjrans');
+--------------------------+
| old_password('dltjrans') |
+--------------------------+
| 337c52a05f635196         |
+--------------------------+
1 row in set (0.00 sec)

mysql>
Print Friendly
Sep 042012
 

DB에서 가능하면 join을 사용하지 않도록 설계를 하면 성능에 많은 도움이 된다.

하지만 어쩔수 없는 경우에는 outer join을 사용하면 빠른 속도로 join이 가능하다.

그래서 left outer join을 자주 사용하게 되는데. 이런 경우 join이 되는 테이블의 데이타가 없는 경우에도 결과값은 생성이 되게 된다.

이런 경우에 join이 되는 테이블의 데이타가 없는 경우에는 아래와 같이 판별이 가능한다.
(MySQL 메뉴얼에서 참고한 내용)

If there is a row in A that matches the WHERE clause, but there is no row in B that matches the ON condition, an extra B row is generated with all columns set to NULL.

실제로 2개의 테이블이 느슨한 연결 상태라서 foreign key가 없는 row가 존재할 수 있다.
아래와 같은 쿼리를 통해서 확인하고, delete 처리가 가능하다.

SELECT *
FROM tb_abc a
LEFT JOIN tb_123 b ON a.title = b.title
WHERE a.TYPE = 'ok'
AND b.STATUS IS NULL

참고 URL : http://dev.mysql.com/doc/refman/5.5/en/left-join-optimization.html

Print Friendly
Aug 282012
 

동일한 계정으로 여러 명이 svn을 사용하는 경우에는 패스워드를 저장하지 않고, commit 하는 사용자별로 자신의 계정을 사용해서 commit을 하는 것이 효과적입니다.

대개 개발서버를 두고 작업을 하는 경우에 이렇게 하면 누가 commit을 하고, 해당 파일을 마지막에 수정했는지를 쉽게 파악이 가능합니다.

svn 을 shell에서 사용할때 패스워드 저장하지 않는 방법입니다.

1. 기존에 저장된 패스워드 삭제

    [smlee@localhost .subversion]$ pwd
    /home/smlee/.subversion

    [smlee@localhost .subversion]$ mv auth oldauth

2. 패스워드 저장하지 않는 옵션 변경

    [smlee@localhost .subversion]$ pwd
    /home/smlee/.subversion

    [smlee@localhost .subversion]$ grep password config
    ### Set password stores used by Subversion. They should be
    ### the order in which password stores are used.
    ### Valid password stores:
    # password-stores = gnome-keyring,kwallet
    ### Both ‘store-passwords’ and ‘store-auth-creds’ can now be
    ### Set store-passwords to ‘no’ to avoid storing passwords in the
    ### but Subversion will never save your password to disk in
    ### Note that this option only prevents saving of *new* passwords;
    ### it doesn’t invalidate existing passwords. (To do that, remove
    store-passwords = no

3. 이후에 svn commit을 하게 되면 마지막 commit 한 사용자의 패스워드를 입력해야만 commit 이 가능해짐
==> 만약 자신의 계정이 아닌 경우에는 아래와 같이 패스워드를 입력하지 않고 엔터만 입력해서 사용자 변경 가능

    [smlee@localhost public_html]$ svn commit
    인증 영역(realm): 0ee1c4cf-d430-49e6-9165-ac7844d2f91e
    ‘smlee’의 암호:
    인증 영역(realm): 0ee1c4cf-d430-49e6-9165-ac7844d2f91e
    사용자명:
Print Friendly
Aug 282012
 

최근의 대부분 웹페이지는 UTF-8을 사용하고 있습니다.

예전에 만들어진 EUC-KR 페이지를 UTF-8로 변환하는 경우가 많이 있습니다.
이런 경우에 일일이 파일을 converting을 해야 하는데요. 간단한 스크립트를 이용해서 편리합니다.

[smlee@localhost ~]# cat conv.sh
#!/bin/sh
 
set -x
iconv -f uhc -t utf-8 $1 > /tmp/a
RET=$?
 
if [ $RET -eq 0 ]; then
        mv /tmp/a $1
else
        echo "FAIL : $1";
fi

위의 스크립트를 ls -1 > 1.sh 로 만든 다음에 vi에서 1.sh를 치환해서 모든 파일에 대해서 conv.sh를 실행하도록 아래와 같이 설정하면 빠르게 치환이 가능합니다.

[smlee@localhost ~]# cat 1.sh
sh conv.sh index.php
sh conv.sh main.php
Print Friendly
Plugin from the creators of Brindes :: More at Plulz Wordpress Plugins