본문 바로가기
[IT 관련 지식]/[DB]

mysql 사용자 생성 및 삭제

by 판톰 2012. 7. 3.
반응형

mysql db생성

root@web:~# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 35

Server version: 5.1.63-0ubuntu0.11.04.1 (Ubuntu)

 

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

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

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

+--------------------+

2 rows in set (0.00 sec)

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

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

[사용자 DB 생성]

>create database DB; 

[사용자 DB 삭제]

>drop database DB;

 

 

[사용자 생성]

>use mysql

 >insert into user(host,user,password) values('접속허용정책','계정명',password('패스워드'));

Ex)

insert into user(host,user,password) values('%','test',password('gh!@#'));

 

접속허용정책 : % = 모든곳에서 접근 허용

 

[사용자 삭제]

>use mysql

 

>delete from user where user='사용자 계정명';

 

[사용자 DB 접근 권한 부여]

>use mysql

>desc db;      [ 권한 옵션 확인]

 

insert into db values('%','test_db','test','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');

 

[DB 적용]

>flush privileges;

 

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

[확인]

root@web:~# mysql -u 사용자 -p DB

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 54

Server version: 5.1.63-0ubuntu0.11.04.1 (Ubuntu)

 

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| test_db            |

+--------------------+

2 rows in set (0.00 sec)

 

mysql> 

반응형

'[IT 관련 지식] > [DB]' 카테고리의 다른 글

select 조건  (0) 2014.08.22