하나씩 설치하다가 잘안되서...
깔끔하게 APM_Setup 으로 설치하였다 ~! (XP환경)

[InnoDB]

1. InnoDB가 사용가능한지 확인해본다.

mysql> show variables like 'have_innodb';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb   | YES   |
+---------------+-------+
1 row in set (0.00 sec)

!!! 여기서 Value에 Disable라고 뜬다면, my.ini를 열어서...
# BDB타입을 사용할지 하지 않을지
#skip-bdb <- 이부분 앞에 #으로 바꿔주고 mysql 재시작 하면 된다 ~


2. 설정 상태 확인한다.
mysql> show status like '%innodb%';
+-----------------------------------+---------+
| Variable_name                     | Value   |
+-----------------------------------+---------+
| Com_show_innodb_status            | 0       |
| Innodb_buffer_pool_pages_data     | 19      |
| Innodb_buffer_pool_pages_dirty    | 0       |
| Innodb_buffer_pool_pages_flushed  | 0       |
| Innodb_buffer_pool_pages_free     | 493     |
| Innodb_buffer_pool_pages_misc     | 0       |
| Innodb_buffer_pool_pages_total    | 512     |
| Innodb_buffer_pool_read_ahead_rnd | 1       |
| Innodb_buffer_pool_read_ahead_seq | 0       |
| Innodb_buffer_pool_read_requests  | 77      |
| Innodb_buffer_pool_reads          | 12      |
| Innodb_buffer_pool_wait_free      | 0       |
| Innodb_buffer_pool_write_requests | 0       |
| Innodb_data_fsyncs                | 3       |
| Innodb_data_pending_fsyncs        | 0       |
| Innodb_data_pending_reads         | 0       |
| Innodb_data_pending_writes        | 0       |
| Innodb_data_read                  | 2494464 |
| Innodb_data_reads                 | 29      |
| Innodb_data_writes                | 3       |
| Innodb_data_written               | 1536    |
| Innodb_dblwr_pages_written        | 0       |
| Innodb_dblwr_writes               | 0       |
| Innodb_log_waits                  | 0       |
| Innodb_log_write_requests         | 0       |
| Innodb_log_writes                 | 1       |
| Innodb_os_log_fsyncs              | 3       |
| Innodb_os_log_pending_fsyncs      | 0       |
| Innodb_os_log_pending_writes      | 0       |
| Innodb_os_log_written             | 512     |
| Innodb_page_size                  | 16384   |
| Innodb_pages_created              | 0       |
| Innodb_pages_read                 | 19      |
| Innodb_pages_written              | 0       |
| Innodb_row_lock_current_waits     | 0       |
| Innodb_row_lock_time              | 0       |
| Innodb_row_lock_time_avg          | 0       |
| Innodb_row_lock_time_max          | 0       |
| Innodb_row_lock_waits             | 0       |
| Innodb_rows_deleted               | 0       |
| Innodb_rows_inserted              | 0       |
| Innodb_rows_read                  | 0       |
| Innodb_rows_updated               | 0       |
+-----------------------------------+---------+
43 rows in set (0.00 sec)

Value에 설정된 값은 아마 my-innodb-heavy-4G.ini 를 편집하면 바뀔것 같다.
지금은 그냥 해보는게 중요해서..ㅎㅎ 건너뜀 ~ㅎ



3. 기존의 테이블 엔진 바꾸기
먼저 테이블 속성을 보자 ~

mysql> use testdb;
mysql> show table status where name='inno_test';
+-----------+--------+---------+------------+------+----------------+-----------
--+-------------------+--------------+-----------+----------------+-------------
--------+---------------------+------------+-----------------+----------+-------
---------+---------+
| Name      | Engine | Version | Row_format | Rows | Avg_row_length | Data_lengt
h | Max_data_length   | Index_length | Data_free | Auto_increment | Create_time
        | Update_time         | Check_time | Collation       | Checksum | Create
_options | Comment |
+-----------+--------+---------+------------+------+----------------+-----------
--+-------------------+--------------+-----------+----------------+-------------
--------+---------------------+------------+-----------------+----------+-------
---------+---------+
| inno_test | MyISAM |      10 | Fixed      |    1 |             65 |          6
5 | 18295873486192639 |         2048 |         0 |           NULL | 2009-11-20 1
5:20:35 | 2009-11-20 15:24:25 | NULL       | utf8_general_ci |     NULL |
         |         |
+-----------+--------+---------+------------+------+----------------+-----------
--+-------------------+--------------+-----------+----------------+-------------
--------+---------------------+------------+-----------------+----------+-------
---------+---------+
1 row in set (0.00 sec)

MyISAM 엔진이다. 이제 InnoDB로 변경 !!!

mysql> alter table inno_test type=innodb;
Query OK, 1 row affected, 1 warning (0.11 sec)
레코드: 1개  중복: 0개  경고: 0개

mysql> show table status where name='inno_test';
+-----------+--------+---------+------------+------+----------------+-----------
--+-----------------+--------------+-----------+----------------+---------------
------+-------------+------------+-----------------+----------+----------------+
----------------------+
| Name      | Engine | Version | Row_format | Rows | Avg_row_length | Data_lengt
h | Max_data_length | Index_length | Data_free | Auto_increment | Create_time
      | Update_time | Check_time | Collation       | Checksum | Create_options |
 Comment              |
+-----------+--------+---------+------------+------+----------------+-----------
--+-----------------+--------------+-----------+----------------+---------------
------+-------------+------------+-----------------+----------+----------------+
----------------------+
| inno_test | InnoDB |      10 | Compact    |    1 |          16384 |       1638
4 |               0 |        16384 |         0 |           NULL | 2009-11-20 15:
20:35 | NULL        | NULL       | utf8_general_ci |     NULL |                |
 InnoDB free: 4096 kB |
+-----------+--------+---------+------------+------+----------------+-----------
--+-----------------+--------------+-----------+----------------+---------------
------+-------------+------------+-----------------+----------+----------------+
----------------------+
1 row in set (0.00 sec)

InnoDB로 변경이 되었다 ~

4. 트랜잭션. rollback, commit 해보기

mysql> select * from inno_test;
+------+------+
| a    | b    |
+------+------+
|    2 | cho  |
+------+------+
1 row in set (0.00 sec)

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> update inno_test set a=3;
Query OK, 1 row affected (0.00 sec)
일치하는 Rows : 1개 변경됨: 1개  경고: 0개

mysql> select * from inno_test;
+------+------+
| a    | b    |
+------+------+
|    3 | cho  |
+------+------+
1 row in set (0.00 sec)

mysql> rollback;
Query OK, 0 rows affected (0.03 sec)

mysql> select * from inno_test;
+------+------+
| a    | b    |
+------+------+
|    2 | cho  |
+------+------+
1 row in set (0.00 sec)

업데이트 쿼리를 하기전에 begin;을 입력하고 쿼리를 수행하면,
실제 데이터가 바로 바뀌지 않는다.
commit; 이 들어오면 실제로 바뀌게 되고 rollback;이 들어오면 적용하지 않게 된다.
이제는 commit;을 해보자.

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> update inno_test set a=3;
Query OK, 1 row affected (0.00 sec)
일치하는 Rows : 1개 변경됨: 1개  경고: 0개

mysql> select * from inno_test;
+------+------+
| a    | b    |
+------+------+
|    3 | cho  |
+------+------+
1 row in set (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.03 sec)

mysql> select * from inno_test;
+------+------+
| a    | b    |
+------+------+
|    3 | cho  |
+------+------+
1 row in set (0.00 sec)

적용이 되었다 ~
트랜잭션에 대해서 좀 더 공부해야겠다 ~~~!

vim 편집기로 작업을 하다가 나도 모르게 컨트롤 Z를 눌러버리니...
바로 백그라운드 작업이 되어버렸다...
다시 vim 으로 편집할려고 하니 읽기전용이 되어 버렸네 ㅠ
kill 로 죽여도 죽은게 아닌듯한 느낌? ㅎ

그래서 명령어를 찾았다 ~~!!

bg : 백그라운드 작업 보기
fg : 백그라운드 작업으로 이동 (포워드그라운드 인가? ㅎ)


#include 
#include 
using namespace std;
int main()
{
int result, sum = 10, divisor=0;
result = sum / divisor;
cout << "Result = " << result << endl;
return 0;
}


위의 코드는 컴파일러가 제수가 0이 되는 에러를 잡지 못한다.
이럴때 assert()를 사용해서 false가 될경우 프로그램이 종료되게 할 수 있다.

#include 
#include 
using namespace std;
int main()
{
int result, sum = 10, divisor=0;
assert(divisor!=0);
result = sum / divisor;
cout << "Result = " << result << endl;
return 0;
}


Output
===================================================================================
t: t.cpp:8: int main(): Assertion `divisor!=0' failed.
Disallowed system call: SYS_kill
===================================================================================

assert() 코드 기능을 사용하고 싶지 않다면 #include 위에
#define NDEBUG 를 넣어주면 된다.


Running SecureCRT from a USB Flash Memory Drive
USB flash memory drives are very handy portable storage media. Also known as Thumbdrives and pen drives, these devices plug into any computer's USB port and are small enough to fit on a keychain or in a pocket. These instructions are for users of SecureCRT 4.1 or later.
To run SecureCRT from a USB drive, you create an installation for SecureCRT manually. This involves copying SecureCRT to the flash drive, creating a license key file for your registration information, and setting up a shortcut to the new installation, with a few other minor modifications. The following instructions are generally applicable to removable USB drives. You may need to make some changes to suit your particular needs and hardware.
   1. Copy the SecureCRT installation folder to the USB drive (C:\Program Files\SecureCRT by default). The top-level directory of my USB device looks like this:
          11/03/2003 21:27 <DIR>     SecureCRT
          11/03/2003 21:27 <DIR>     Known Hosts
          11/03/2003 22:04       206 SecureCRT.bat
   2. Copy your Config folder into the USB device's SecureCRT folder. The Config folder is usually found under:
        C:\Documents and Settings\%USERNAME%\Application
          Data\VanDyke\SecureCRT\Config
      The USB device directory structure should now show a \SecureCRT\Config folder.
  3. In Notepad or another text editor, create a text file named SecureCRT.lic containing your license information, and place that file in the newly created SecureCRT folder as well. The format of the SecureCRT.lic file is as follows:
          Name=<name from registration letter>
          Company=<company name from registration letter>
          Serial Number=03-xx-xxxxxx
          Key=nnnnnn nnnnnn nnnnnn nnnnnn nnnnnn nnnnnn nnnnnn nnnnnn
          Issue Date=nn-nn-nnnn
   4. Next you need to set up a desktop shortcut pointing to SecureCRT.exe or to a batch file. The one you choose depends on how the flash drive is treated by your version of Windows. If you know that the removable device is always going to be assigned the same drive letter, you can just create a shortcut to the SecureCRT executable with the /F flag (more on this below). If you don't always know which drive letter the device will be given, you will need to create a short batch file (a VBScript would also work) to launch SecureCRT, since shortcuts can't use relative paths in their target names.
      In either case, the use of the /F flag is critical. Otherwise SecureCRT will try to create the Config folder in your Application Data folder, which is not what you want.
      To create a simple shortcut, use the /F option, and specify the path to the Config folder. For instance, if you know G: will always be the location of your removable device, you would create a shortcut with the target:
        G:\SecureCRT\SecureCRT.EXE /F G:\SecureCRT\Config
      To start SecureCRT using a batch file, first create a text file that looks like this:
        ---
        @echo off
        REM   *  SecureCRT launcher
        REM   *  Allows relative paths on my removable device
        SET SCRT=.\SecureCRT\SecureCRT.EXE
        SET CONF=.\SecureCRT\Config
        START %SCRT% /F %CONF%
        ---
      The batch file can be saved either on the flash drive or on your hard disk. Then create a shortcut that executes the batch file to start SecureCRT.
   5. If you use SSH2 for any connections, you need to edit SSH2.ini in the Config folder to point at the correct location for the host key database. If you place the database at the top level of your device, the corresponding line in SSH2.ini would be:
        S:"Host Key Database Location"=..\..\Known Hosts\
   6. Finally, if you use public-key authentication with any of your sessions, you can place your public and private keys on the device as well. If you use password authentication this step is unnecessary.
==============================================

현재 캐릭터셋 확인하기

mysql> show variables like 'c%';
+--------------------------+----------------------------------------+
| Variable_name            | Value                                  |
+--------------------------+----------------------------------------+
| character_set_client     | latin1                                 |
| character_set_connection | latin1                                 |
| character_set_database   | latin1                                 |
| character_set_filesystem | binary                                 |
| character_set_results    | latin1                                 |
| character_set_server     | latin1                                 |
| character_set_system     | utf8                                   |
| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |
| collation_connection     | latin1_swedish_ci                      |
| collation_database       | latin1_swedish_ci                      |
| collation_server         | latin1_swedish_ci                      |
| completion_type          | 0                                      |
| concurrent_insert        | 1                                      |
| connect_timeout          | 10                                     |
+--------------------------+----------------------------------------+
14 rows in set (0.00 sec)


mysql> status
--------------
mysql  Ver 14.12 Distrib 5.0.67, for redhat-linux-gnu (x86_64) using readline 5.1

Connection id:          73
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.0.67-log Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 15 hours 27 min 55 sec

Threads: 1  Questions: 791  Slow queries: 0  Opens: 39  Flush tables: 1  Open tables: 34  Queries per second avg: 0.014
--------------

이런식으로 뜬다.

변경하기
vi /etc/my.cnf

[client]
default-character-set=euckr

[mysqld]
default-character-set=euckr
init_connect=SET collation_connection=euckr_korean_ci
init_connect=SET NAMES euckr
character-set-server=euckr
collation-server=euckr_korean_ci

[mysqldump]
default-character-set=euckr

[mysql]
default-character-set=euckr

euckr 및 euckr_korean_ci 를 원하는 해당 캐릭터셋으로 바꾸어주면 된다.

추가 및 변경 후, MySQL 을 재시작 해주어야 적용된다.

service mysqld restart

#include <stdio.h>
 
//using namespace std;
 
int main()
{
    int i,j,k,s,e,min,n=8;
    int path[8],path_cnt=0;
    // unconnect
    const int U=static_cast<unsigned int>(-1)/2;
    int data[8][8] = {
        {0,2,U,U,U,3,U,U},
        {2,0,4,1,U,U,U,U},
        {U,4,0,U,3,U,U,U},
        {U,1,U,0,3,U,2,U},
        {U,U,3,3,0,U,U,4},
        {3,U,U,U,U,0,6,U},
        {U,U,U,2,U,6,0,4},
        {U,U,U,U,4,U,4,0}};
    bool v[8];
    int distance[8],via[8];
 
    // 출발, 도착 정점
    s=0,e=7;
 
    // 초기화
    for(i=0;i<n;i++)
    {
        v[i]=false;
        distance[i]=U;
    }
    distance[s]=0;
 
    // 찾기
    for(i=0;i<n;i++)
    {
        min=U;
        for(j=0;j<n;j++)
        {
            if(v[j]==false && distance[j]<min)
            {
                k=j;
                min=distance[j];
            }
        }
        v[k]=true;
        if(min==U)
            break;
        for(j=0;j<n;j++)
        {
            if(distance[k]==U || data[k][j]==U)
                continue;
            if(distance[j]>distance[k]+data[k][j])
            {
                distance[j]=distance[k]+data[k][j];
                via[j]=k;
            }
        }
    }
    // 최단 비용
    printf("%d\n",distance[e]);
    // 최단 경로
    k=e;
    while(true)
    {
        path[path_cnt++]=k;
        if(k==s)
            break;
        k=via[k];
    }
    for(i=path_cnt-1;i>=1;i--)
        printf("%d -> ",path[i]);
    printf("%d\n",path[i]);
 
    return 0;
} 


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 150
FILE *fp,*fp1;
main(){
	int i,j,k,m,n,s_top,len,o_i;
	char stack[MAX];
	char output[MAX];
	int imp[MAX];
	char sik[MAX];
	
	fp=fopen("input.txt","r");
	fp1=fopen("output.txt","w");

	fscanf(fp,"%s",sic);
	len=strlen(sic);

	for(i=(int)'0';i<=(int)'9';i++)
		imp[i]=5;
	imp[(int)'(']=3;
	imp[(int)'<']=2;
	imp[(int)'>']=2;
	imp[(int)'%']=1;
	imp[(int)')']=0;
		
	for(i=0,s_top=-1,o_i=-1;i<len;i++){
		if(imp[(int)sik[i]]==5)
			output[++o_i]=sik[i];
		else{
			switch(imp[(int)sik[i]]){
			case 3:

				stack[++s_top]=sik[i];
				break;
			case 2:
				if(imp[(int)stack[s_top]]>=imp[(int)sik[i]]){
					while(imp[(int)stack[s_top]]>=imp[(int)sik[i]])
						output[++o_i]=stack[s_top--];
				}
				else
					stack[++s_top]=sik[i];
				break;
			case 1:
				if(imp[(int)stack[s_top]]>=imp[(int)sik[i]]){
					while(imp[(int)stack[s_top]]>=imp[(int)sik[i]])
						output[++o_i]=stack[s_top--];
				}
				else
					stack[++s_top]=sik[i];
				break;






	
	fprintf(fp1,"Impossible\n");

	fclose(fp);
	fclose(fp1);
}
#include<stdio.h>
int miro[10][10],chk[11][11]={0},path[100][2];
int maxpath[100][2],minpath[100][2];
int max=-9999,min=9999;
int row,col,st_x,st_y,maxcnt,mincnt,maxsum,minsum;
FILE *fp,*fp1;

void back(int x,int y,int sum,int cnt){
	int i,j;
	path[cnt][0]=x;
	path[cnt][1]=y;
	chk[x][y]=1;
	if(x==row && y==col){
		if(sum>max){
			for(i=1;i<=cnt;i++){
				maxpath[i][0]=path[i][0];
				maxpath[i][1]=path[i][1];
			}
			max=sum;
			maxcnt=cnt;
		}
		else if(sum<min){
			for(i=1;i<=cnt;i++){
				minpath[i][0]=path[i][0];
				minpath[i][1]=path[i][1];
			}
			min=sum;
			mincnt=cnt;
		}
		chk[x][y]=0;
	}
	else{
		if(!chk[x][y+1])
			back(x,y+1,miro[x][y+1]+sum,cnt+1);
		if(!chk[x+1][y])
			back(x+1,y,miro[x+1][y]+sum,cnt+1);
		if(!chk[x][y-1])
			back(x,y-1,miro[x][y-1]+sum,cnt+1);
		if(!chk[x-1][y])
			back(x-1,y,miro[x-1][y]+sum,cnt+1);
		chk[x][y]=0;
	}
}

main(){
	int i,j;
	fp=fopen("input.txt","r");
	fp1=fopen("output.txt","w");	
	fscanf(fp,"%d %d",&row,&col);
	for(i=1;i<=row;i++){
		for(j=1;j<=col;j++){
			fscanf(fp,"%d",&miro[i][j]);
		}
	}
	fscanf(fp,"%d %d",&st_x,&st_y);
	for(i=0;i<=row+1;i++){
		for(j=0;j<=col+1;j++){
			if(i==0 || i==row+1 || j==0 || j==col+1)
				chk[i][j]=1;
		}
	}
	back(st_x,st_y,miro[st_x][st_y],1);
	fprintf(fp1,"최대경로:");
	for(i=1;i<=maxcnt;i++)
		fprintf(fp1,"(%d,%d)",maxpath[i][0],maxpath[i][1]);
	fprintf(fp1,"\n최대합 : %d\n",max);
	fprintf(fp1,"최소경로:");
	for(i=1;i<=mincnt;i++)
		fprintf(fp1,"(%d,%d)",minpath[i][0],minpath[i][1]);
	fprintf(fp1,"\n최소합 : %d\n",min);
}


+ Recent posts