관리 메뉴

moozi

jsp mysql db생성, user생성, 테이블생성 본문

글로벌IT_2023/글로벌IT_2023

jsp mysql db생성, user생성, 테이블생성

moozi 2023. 2. 13. 13:19

-- root 로 접속 해서

create user 'musthave'@'%' identified by '1234'; 

grant all privileges on *.* to 'musthave'@'%' identified by '1234'; --  모든DB.모든Table을 사용할 수 있는 권한. '%'는 원격접속허용. 'localhost'는 로컬접속만 가능

 

-- mysql 8.X 버젼에서는

grant all privileges on *.* to 'musthave'@'%' with grant option;

 

 

 

 

-- musthave로 접속해서

create database jspdb default charset utf8 collate utf8_general_ci;

use jspdb;

create table member (
    id varchar(10) not null,
    pass varchar(10) not null,
    name varchar(30) not null,
    regidate datetime default now() not null,
    primary key (id)
);

create table board (
    num int primary key auto_increment,
    title varchar(200) not null,
    content varchar(2000) not null,
    id varchar(10) not null,
    postdate datetime default now() not null,
    visitcount int
);

alter table board
    add constraint board_mem_fk foreign key (id)
    references member (id);


insert into member (id, pass, name) values ('musthave', '1234', '머스트해브');
insert into board  (title, content, id, postdate, visitcount) 
values ( 'jsp란?', 'Java Server Pages 입니다.', 'musthave', now(), 0);
    
  

select * from member;
select * from board;

'글로벌IT_2023 > 글로벌IT_2023' 카테고리의 다른 글

2/13 코딩내용  (0) 2023.02.13
jsp연습문제04  (0) 2023.02.13
jsp연습문제03  (0) 2023.02.10
jsp연습문제02  (0) 2023.02.09
todoApp.jsp with jQuery  (0) 2023.02.09
Comments