mariaDB 환경설정 계정 생성 및 권한 부여

Updated:

마리아디비에 접속

mysql -u root -p

Enter password: 패스워드 입력

데이터베이스 리스트 확인

show databases;

없다면 생성

create database DB명;

기본으로 생성되어 있는 mysql 데이터베이스를 사용한다

use mysql;

mysql의 user 테이블에서 이미 생성된 계정 확인

select host, user, password from user;

mysql은 보안상 기본적으로 외부접속을 허용하지 않기 때문에 계정을 생성할떄 특정 IP 혹은 localhost 를 지정하거나 %를 지정하여 외부접속을 허용할 수 있다.

user1 계정 생성

create user ‘계정아이디’@’접속위치’ identified by ‘패스워드’;

ex. create user ‘user1’@’%’ identified by ‘user!@#$’;

user1 권한 주기

grant all privileges on DB이름.테이블 to ‘계정아이디’@’접속위치’;

ex. grant all privileges on testDB.* to ‘user1’@’localhost’;
//localhost 는 내부에서만 접속가능 grant select on testDB.* to ‘user1’@’%’;

권한 확인

show grants for ‘user1’@’접속위치’;

계정 삭제

drop user ‘계정아이디’@’접속위치’;

ex. drop user ‘user1’@’%’;

권한 삭제

revoke all on DB이름.테이블 FROM ‘계정아이디’@’접속위치’;

Tags: , ,

Categories:

Updated:

Leave a comment