% mysql -u root -p
Enter password:
> create database mydb;
> show databases;

> use mydb;
> drop database mydb;

> create user 'zerobase'@'localhost' identified by '1234';
-- 확인
> select host, user from user;

> create user 'zerobase'@'%' identified by '5678';
> select host, user from user;


> create database mydb;
> create user 'zero'@'localhost' identified by '1234';
> show grants for 'zero'@'localhost';
> grant all on mydb.* to 'zero'@'localhost';
> revoke all on mydb.* from 'zero'@'localhost';
> flush privileges;
> create database zerobase default character set utf8mb4;
> use zerobase;
> create table mytable
-> (
-> id int,
-> name varchar(16)
-> );
> show tables;
> desc mytable;

> alter table mytable rename person;

> alter table person add column agee double;

> alter table person modify column agee int;

> alter table person change column agee age int;

> alter table person drop age;
> drop table person;
▷ 데이터 추가
> create table person(
-> id int,
-> name varchar(16),
-> age int,
-> sex CHAR
-> );

> insert into person (id, name, age, sex)
-> values(1, '이효리', 43, 'F');
> insert into person
-> values(2, '이상순', 48, 'M');

▷ 데이터 조회 / 조건
> select * from person;
> select name, age, sex from person;
> select * from person where sex='F';
> select * from person where age=50;

▷ 데이터 수정
> update person set age=23 where name='이효리';
> update person set name='이미주' where id=2;
▷ 데이터 삭제
> delete from person where name='이상순';
> delete from animal;

> drop table person;

"이 글은 제로베이스 데이터 취업 스쿨의 강의 자료 일부를 발췌하여 작성되었습니다."