mysql -u (계정명) -p
mysql -h (ip주소) -u (계정명) -p
//로컬, 원격 모두 기본 포트 3306을 사용하지 않을 경우 -P(포트번호)를 입력해야 한다.
//원격지의 특정 DB에 접속하려면 -p (DB명)
계정 관리는 우선 mysql 데이터베이스로 접속한다
use mysql;
create user '계정명'@localhost identified by '비밀번호';
@localhost는 내부 IP만, @%는 외부 IP도 접속 가능
drop user test@localhost;
select host, user from user;
select user();
use mysql;
show databases;
select database();
create schema 'DB명';
drop database testtest;
grant all privileges on 'DB명'.'테이블명' to '계정명'@localhost;
위 명령어 뒤에 with grant option 사용 시 grant로 권한 부여받은 계정에서 권한을 다시 줄 수 있다
show grants for '계정명'@localhost; // 권한 확인
revoke all on 'DB명'.'테이블명' from '계정명'@localhost; // 권한 삭제