유돌이

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2019. 10. 11. 10:27 유닉스*리눅스*SE

1. mysql 접속

   mysql -u root -p

   패스워드 입력

 

2. use mysql

 

3. update user set password=password('암호') where user = '계정명';

 

4. flush privileges;

posted by 유돌이
2019. 10. 11. 10:27 유닉스*리눅스*SE

select max(length('필드명')) from '테이블명'

posted by 유돌이
2019. 10. 11. 10:26 유닉스*리눅스*SE

1. 계정생성

   use mysql;

   -------------------------------------------------------------------------

   create user 사용자ID; //사용자 추가

   create user 'userid'@localhost identified by '비밀번호'; //사용자 &비밀번호 추가

   create user 'userid'@'%' identified by '비밀번호'; //외부 접속 허용

   -------------------------------------------------------------------------

​2. 권한설정

  - user 권한 부여
  grant select, insert, update, delete, create, drop, alter on 지정DB이름.*to '아이디'@'localhost';
(all privileges : 모든 권한 / *.* : 모든DB / with grant option : 권한위임가능)

 

  - user 권한 보기
  show grants for '아이디'@'localhost(또는%)';


  - 권한 적용
  flush privileges;
 

3. 계정삭제

   drop user 'userid'@localhost;

 

 

4.  한번에 하기

use mysql;

 

INSERT INTO user (host, user, password) VALUES ('localhost', 'ID', password('pw'));

 

INSERT INTO db (Host, Db, User, Select_priv, Insert_priv,Update_priv, Delete_priv, Create_priv, Drop_priv)VALUES('localhost','id','id', 'Y', 'Y', 'Y', 'Y','Y','Y');

 

GRANT ALL on db.* TO 'id';  

 

GRANT ALL on db.* TO 'id'@'localhost';      

 

update user set password=password("pw") where User="id";

 

 

flush privileges;

'유닉스*리눅스*SE' 카테고리의 다른 글

[mysql] 계정 비밀번호 변경  (0) 2019.10.11
[MYSQL] 필드 최대길이 구하기  (0) 2019.10.11
[mysql] slow query log 설정  (0) 2019.10.11
[GIT] branch 이름 변경하기  (0) 2019.10.07
[git] git 명령어 관련  (0) 2019.10.07
posted by 유돌이
2019. 10. 11. 10:26 유닉스*리눅스*SE

slow_query_log=1

=> 슬로우쿼리는 남기도록 하는 설정 입니다. (1 :  enable, 0 : disable)

 

log_query_time=2

=> 단위는 초단위이며, 쿼리가 2초이상 걸린 경우 로그로 남갑니다. 기본은 10초입니다.

 

log_slow_queries=var/log/mysql_slow.log

=> 슬로우쿼리가 저장될 공간을 설정합니다.

 

slow_qurey_log=on

=> 슬로우쿼리 설정유무를 나타냅니다. (on/off)

 

long_query_time=5.000000

=> 슬로우쿼리 구분기준(5초로설정) 입니다. 설정하지 않으면 기본값 10초로 동작합니다.

 

해당 내용을 수정후 mysql 재시작하면 적용됩니다.

( service mysql restart )

 

=========================================================================================
[로그 보는법]

  Query_time : 7.359190
  쿼리가 실행된 시간입니다. 2초 이상으로 설정했으므로 7.3초가 걸린 쿼리가 로그에 남아있습니다. 시스템에 따라 쿼리 내용에 따라 해당 시간이 오래 걸린다고 판단할 수도 있고 아닐 수도 있습니다. 시스템 성격이나 쿼리 성격에 비추어 해당 쿼리를 판단하면 됩니다.

 

  Lock_time : 0.000054
  쿼리가 실행되지 못하고 lock되어 있는 시간을 나타냅니다. 쿼리 실행 시간 중 상당 부분이 lock 시간인 경우 쿼리 자체의 문제보다 구조적인 문제에 초점을 맞춰야 합니다. lock이 걸리는 원인을 찾아 제거하면 쿼리 속도를 올릴 수 있습니다.

 

  select count(*) from Table_a;
  실제로 오래 걸린 쿼리문입니다. 해당 쿼리문에 문제가 있는지 점검하여 개선할 수 있습니다. 쿼리 개선은 쿼리 자체의 문법 수정도 있겠지만 테이블 스키마 변경, DBMS 설정 변경 등에 의해서 수행될 수 있습니다. 쿼리 개선의 경우는 상당히 많은 내용이 있으므로 따로 작성할 필요가 있습니다.

posted by 유돌이
2019. 10. 7. 18:16 유닉스*리눅스*SE

git branch -m 변경전_branch_name 새로운_branch_name

posted by 유돌이
2019. 10. 7. 18:15 유닉스*리눅스*SE

(remote 저장소 살펴보기)

git remote show

==================================================

(리모트명에 구체적인 정보 확인)

git remote show humax

==================================================

(현재 디렉토리를 새로운 Git 저장소로 설정)

git init

==================================================

(github 저장소로부터 데이터를 복사 [동시에 origin 리모트 저장소를 생성])

git clone [github 저장소 url]

==================================================

(원격 브랜치 선택하기, 해당 브랜치명으로 트래킹)

git checkout -t [브랜치명]

==================================================

(파일을 staging area에 추가)

git add [파일이름] [옵션]

- A, --all : 변경된 모든파일 추가

==================================================

(stage에 추가된 파일 목록을 커밋함.)

git commit [옵션]

-m [메시지] : 커밋 메시와 함께 커밋

-a : 자동으로 add를 진행한 후 커밋

-v : 커밋 메시지에 diff의 내용 포함

==================================================

(연결된 브랜치명 확인)

git branch [옵션]

-v : 각 브랜치의 마지막 커밋 메시지를 보여줌

-merged : merge된 브랜치 목록확인

-no-merged : merge하지 않은 브랜치 목록확인

-d : 브랜치 삭제

-D : 브랜치 강제삭제

-r : 원격 브랜치 목록보기

-a : 로컬 브랜치 목록보기

- m : 브랜치 이름 바꾸기

=> git branch -m branch_name change_branch_name

==================================================

(바로 전 커밋으로 돌아감)

git reset : 직전의 add 이전의 상태로 staging area를 되돌림

git reset --hard HEAD : 직전의 커밋을 되돌림

git reset --soft HEAD^ : 코드는 살리고 commit만 취소하기

git reset --merge : merge 취소하기

git reset --hard HEAD && git pull : git 코드 강제로 모두 받아오기

git checkout HEAD~1 : 이전커밋으로 이동

git checkout HEAD~10 : 숫자만큼 이전커밋으로 이동

git checkout master : 다시 돌아오는 방법

(특정커밋으로 돌아가기)

git checkout 9d51a7 : 고유번호 앞 6자리만 적어주면 알아서 식별하여 이동 (커밋2로 돌아가기)

----------------------------------------------------------

commit a1d1bfe13...

Author : Wasabi

Date : Tue Jun 16 10:08:29 2019 +0900

(커밋3)

commit 9d51a77c6..

Author : Wasabi

Date : Tue Jun 15 10:08:29 2019 +0900

(커밋2)

commit dfdebeb77...

Author : Wasabi

Date : Tue May 16 10:08:29 2019 +0900

(커밋1)

----------------------------------------------------------

==================================================

(git서버에서 최신 코드 받아오기)

git fetch

==================================================

(git서버에서 최신 코드 받아와 merge 하기)

git pull

==================================================

(현재 위치 커밋과 브랜치의 커밋을 합침)

git merge [브랜치명]

==================================================

(working directory와 staging area의 상태 확인)

git status

==================================================

(working directory와 staging area의 차이 확인)

git diff [옵션]

--staged : 마지막 커밋과 staging area의 차이확인

==================================================

(로그확인 변경사항 확인가능)

git log [옵션]

-p : 변경사항 확인

--oneline : 커밋 메시지만 한줄씩 표시

--all : 모든 브랜치 로그표시

--graph : 브랜치 트리 그래프 표시

===================================================

(기타)

git config --global user.name “user_name ” : git 계정Name 변경하기

git config --global user.email “user_email” : git 계정Mail변경하기

git stash / git stash save “description” : 작업코드 임시저장하고 브랜치 바꾸기

git stash pop : 마지막으로 임시저장한 작업코드 가져오기

git branch --set-upstream-to=remote_path/branch_name :

git pull no tracking info 에러해결

posted by 유돌이
2019. 10. 4. 09:39 델파이

// IPHLPAPI.DLL 의 Delphi 헤더파일은 JEDI 에서 받을 수 있습니다
//   ftp://delphi-jedi.org/api/IPHlpAPI.zip

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Winsock, IpHlpApi, IPTypes, IpIfConst;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function GetAdaterTypeName(Type_:Uint):string;
begin
  case Type_ of
    MIB_IF_TYPE_ETHERNET: begin
      result:='Ethernet adapter';
    end;
    MIB_IF_TYPE_TOKENRING: begin
      result:='oken Ring adapter';
    end;
    MIB_IF_TYPE_FDDI: begin
      result:='FDDI adapter';
    end;
    MIB_IF_TYPE_PPP: begin
      result:='PPP adapter';
    end;
    MIB_IF_TYPE_LOOPBACK: begin
      result:='Loopback adapter';
    end;
    MIB_IF_TYPE_SLIP: begin
      result:='Slip adapter';
    end;
    else begin
      result:='Unknow Adapter type';
    end;
  end;
end;

function GetNodeTypeName(Type_:Uint):string;
begin
  case Type_ of
    1: result:='Broadcast';
    2: result:='Peer to peer';
    4: result:='Mixed';
    8: result:='Hybrid';
    else begin
      result:='Unknown';
    end;
  end;
end;

function Formatmac(pAdapt:PIP_ADAPTER_INFO):string;
var
  i:Integer;
begin
  result:='';
  for i:=0 to pAdapt^.AddressLength-1 do begin
    if (i = (pAdapt^.AddressLength - 1)) then begin
      result:=result+Format('%.2X', [Integer(pAdapt^.Address[i])]);
    end else begin
      result:=result+Format('%.2X-', [Integer(pAdapt^.Address[i])]);
    end;
  end;
end;


function B2S(b:Boolean):String;
begin
  if b then result:='Yes' else result:='No';
end;

Procedure IPConfig(Target:TStrings);
var
  Err:DWORD;
  pFixedInfo:PFIXED_INFO;
  FixedInfoSize:DWORD;
  pAdapterInfo, pAdapt:PIP_ADAPTER_INFO ;
  AdapterInfoSize:DWORD;
  pAddrStr:PIP_ADDR_STRING;
begin
  // Get the main IP configuration information for this machine using a FIXED_INFO structure
  Err := GetNetworkParams(NIL, FixedInfoSize);
  if (Err <> 0) then begin
    if (Err <> ERROR_BUFFER_OVERFLOW) then begin
      raise Exception.CreateFmt(
        'GetNetworkParams sizing failed with error %d',
        [Err]
      );
    end;
  end;

  // Allocate memory from sizing information
  pFixedInfo := PFIXED_INFO(GlobalAlloc(GPTR, FixedInfoSize));
  if not Assigned(pFixedInfo) then begin
    raise Exception.Create(
      'Memory allocation error'
    );
  end;

  Err := GetNetworkParams(pFixedInfo, FixedInfoSize);
  if (Err = 0) then begin
    Target.Add(Format('Host Name . . . . . . . . . : %s', [pFixedInfo^.HostName]));
    Target.Add(Format('DNS Servers . . . . . . . . : %s', [pFixedInfo^.DnsServerList.IpAddress.S]));
    pAddrStr := pFixedInfo^.DnsServerList.Next;
    while (pAddrStr<>NIL) do begin
      Target.Add(Format('%s', [pAddrStr^.IpAddress.S]));
      pAddrStr := pAddrStr^.Next;
    end;

    Target.Add('Node Type . . . . . . . . . : '+GetNodeTypeName(pFixedInfo^.NodeType));

    // if you really need it....
    //    printf("\tNetBIOS Scope ID. . . . . . : %s\n", pFixedInfo->ScopeId);
    //    printf("\tIP Routing Enabled. . . . . : %s\n", (pFixedInfo->EnableRouting ? "yes" : "no"));
    //    printf("\tWINS Proxy Enabled. . . . . : %s\n", (pFixedInfo->EnableProxy ? "yes" : "no"));
    //    printf("\tNetBIOS Resolution Uses DNS : %s\n", (pFixedInfo->EnableDns ?"yes" : "no"));
  end; // if

  //
  // Enumerate all of the adapter specific information using the IP_ADAPTER_INFO structure
  // Note:  IP_ADAPTER_INFO contains a linked list of adapter entries.
  //
  AdapterInfoSize := 0;
  Err := GetAdaptersInfo(NIL, AdapterInfoSize);
  if (Err <> 0) then begin
    if (Err <> ERROR_BUFFER_OVERFLOW) then begin
      raise Exception.CreateFmt(
        'GetAdaptersInfo sizing failed with error %d',
        [Err]
      );
    end;
  end;

  // Allocate memory from sizing information
  pAdapterInfo := PIP_ADAPTER_INFO(GlobalAlloc(GPTR, AdapterInfoSize));
  if not Assigned(pAdapterInfo) then begin
    raise Exception.Create(
      'Memory allocation error'
    );
  end;

  // Get actual adapter information
  Err := GetAdaptersInfo(pAdapterInfo, AdapterInfoSize);
  if (Err <> 0) then begin
    raise Exception.CreateFmt('GetAdaptersInfo failed with error %d',[Err]);
  end;

  pAdapt := pAdapterInfo;

  while (pAdapt<>NIL) do begin
    Target.Add(GetAdaterTypeName(pAdapt^.Type_));
    Target.Add(pAdapt^.AdapterName);
    Target.Add(Format('Description . . . . . . . . : %s',[pAdapt^.Description]));
    // mac address
    Target.Add('Physical Addresses (MAC). . . . : '+Formatmac(pAdapt));
    Target.Add('DHCP Enabled. . . . . . . . : '+B2S(pAdapt^.DhcpEnabled<>0));

    // list ip addresses
    pAddrStr := @pAdapt^.IpAddressList;
    while (pAddrStr<>NIL) do begin
      Target.Add('IP Address. . . . . . . . . : '+pAddrStr^.IpAddress.S);
      Target.Add('Subnet Mask . . . . . . . . : '+pAddrStr^.IpMask.S);
      pAddrStr := pAddrStr^.Next;
    end; // end

    // list gateways
    Target.Add('Default Gateway . . . . . . : '+pAdapt^.GatewayList.IpAddress.S);
    pAddrStr := pAdapt^.GatewayList.Next;
    while(pAddrStr <>NIL) do begin
      Target.Add(pAddrStr^.IpAddress.S);
      pAddrStr := pAddrStr^.Next;
    end; // while

    // DCHP
    Target.Add('DHCP Server . . . . . . . . : '+pAdapt^.DhcpServer.IpAddress.S);

    // WINS
    Target.Add('Primary WINS Server . . . . : '+pAdapt^.PrimaryWinsServer.IpAddress.S);
    Target.Add('Secondary WINS Server . . . : '+pAdapt^.SecondaryWinsServer.IpAddress.S);

  (*

    // if you really need it....
        struct tm *newtime;

        // Display coordinated universal time - GMT
        newtime = gmtime(&pAdapt->LeaseObtained);
        printf( "\tLease Obtained. . . . . . . : %s", asctime( newtime ) );

        newtime = gmtime(&pAdapt->LeaseExpires);
        printf( "\tLease Expires . . . . . . . : %s", asctime( newtime ) );
  *)

    // next adapter
    pAdapt := pAdapt^.Next;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  IPConfig(Memo1.Lines);
end;

end.

posted by 유돌이
2019. 10. 4. 09:39 델파이

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Winsock, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  function SendARP(Destip,scrip:DWORD;pmacaddr:PDWORD;VAR phyAddrlen:DWORD):DWORD; stdcall ;external 'iphlpapi.dll' ;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function GetmacFromIP(IP: String): String;
  type
    Tinfo = array[0..7] of byte;
var
  dwTargetIP: dword;
  dwmacAddress: array[0..1] of DWORD;
  dwmacLen: DWORD;
  dwResult: DWORD;
  X: Tinfo;
  stemp:string;
  iloop:integer;
begin
  dwTargetIP := Inet_Addr(pchar(ip));
  dwmacLen := 6;
  dwResult := SendARP(dwtargetip,0,@dwmacaddress[0], dwmaclen);
  if dwResult= NO_ERROR then
  begin
    x:= tinfo(dwmacAddress);

    for iloop:= 0 to 5 do
    begin
      stemp:= stemp+inttohex(x[iloop],2);
    end;

    Result:= stemp;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  // Edit1 에 도메인 내의 IP를 입력하고 버튼을 클릭하면 mac 주소를 구해옵니다
  Edit2.Text := GetmacFromIP(Edit1.Text);
end;

end.

posted by 유돌이
2019. 10. 2. 11:39 델파이

// Call CoCreateGuid. The last six bytes are equal to the mac address of
// the Ethernet card. (Note that if you have more than one NIC in your
// computer, you'll get the mac address of one of them, but you can't
// easily control which one.)

// Sneeky... I like it! This will work quite neatly on systems without an
// ethernet card as well. AFAIK this part of the GUID is constant even if you
// only have PPP or even no-networking installed. A useful source of machine
// unique IDs...makes you wonder what the fuss about the PIII ID was about(not
// that I think it's a good idea ;)

// Tip: 델파이 IDE에서 Ctrl-Shift-G 를 눌러보세요...
// GUID가 생성 되는데 뒤에 6바이트(2자리씩 12글자) 는 네트워크 환경이
// 있다면 mac-address 와 같습니다
// PPP or even no-networking

function GetNicAddr: AnsiString;
const
  GUID_MAX = 72;
var
  guid: TGuid;
  buf: array[0..GUID_MAX] of WideChar;
begin
  CoCreateGuid(@guid);
  StringFromGUID2(guid, buf, GUID_MAX);
  Result := Copy(WideCharToString(buf),26,12);
end;

posted by 유돌이
2019. 10. 2. 11:39 델파이

타입

범위

형식

Integer

-2147483648 ~ 2147483647

부호를 가진 32bits (4 Bytes)

Cardinal

0 ~ 4294967295

부호 없는 32bits (4 Bytes)

  <?XML:NAMESPACE PREFIX = O />

 

 

ShortInt

-128 ~ 127

부호를 가진 8bits (1 Byte)

Byte

0 ~ 255

부호 없는 8bits (1 Byte)

SmallInt

-32768 ~ 32767

부호를 가진 16bits (2 Bytes)

Word

0 ~ 65535

부호 없는 16bits (2 Bytes)

LongInt

-2147483648 ~ 2147483647

부호를 가진 32bits (4 Bytes)

LongWord

0 ~ 4294967295

부호 없는 32bits (4 Bytes)

Int64

-263 ~ 263-1

(-9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807)

부호를 가진 64bits (8 Bytes)

Uint64

0 ~ 264-1

(0 ~ 18,446,744,073,709,551,615)

부호 없는 64bits (8 Bytes)

 

출차 : http://hook.tistory.com/153 

posted by 유돌이