본문 바로가기
프로그래밍

mysql 데이터베이서 생성 & 계정 생성 및 권한 주기

by 대도루피 2007. 7. 16.
반응형
 

ROOT로그인하기

[daforu@os daforu]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 66 to server version: 4.0.18-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


데이터베이스만들기

mysql> create database db명;
Query OK, 1 row affected (0.00 sec)

계정생성SQL문
mysql> GRANT USAGE ON *.* TO 아이디@localhost IDENTIFIED BY "비밀번호";
Query OK, 0 rows affected (0.00 sec)

생성한데이터베이스에 사용권한 부여하기

mysql> use db명;
Database changed
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON db명.* TO 아이디@localhost;
Query OK, 0 rows affected (0.01 sec)

***


또는


mysql> GRANT all ON db명.* TO 아이디@localhost; <- 선택디비관련모든권한주기
Query OK, 0 rows affected (0.00 sec)


권한을 다시 로드하기

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)


.. 다시 로그인

[daforu@os bin]$ pwd
/usr/local/mysql/bin
[daforu@os bin]$ mysql -u 아이디 -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 90 to server version: 4.0.18-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

현재 계정에 있는 테이블은 2개!

mysql> show databases;
+-------------+
| Database    |
+-------------+
| blog_deokae |
| test        |
+-------------+
2 rows in set (0.00 sec)


반응형