cmd >>
mysql 계정 확인
id : newuser
C:\Users\HI> mysql -u newuser -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 8.0.31 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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 grants;
+------------------------------------------------------------------------------------------------+
| Grants for newuser@localhost |
+------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `newuser`@`localhost` |
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE, SHOW VIEW ON `users`.* TO `newuser`@`localhost` |
+------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
database 확인
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| performance_schema |
| users |
+--------------------+
3 rows in set (0.00 sec)
newuser@localhost 여기에 create 권한이 없어서 table 생성못했음
mysql> create table users(
-> id varchar(10) primary key,
-> name varchar(20) not null,
-> password varchar(10) not null
-> ) ;
ERROR 1142 (42000): CREATE command denied to user 'newuser'@'localhost' for table 'users'
mysql> grant ALL on users to newuser@localhost;
ERROR 1142 (42000): CREATE, DROP, GRANT, REFERENCES, INDEX, ALTER, CREATE VIEW, TRIGGER command denied to user 'newuser'@'localhost' for table 'users'
mysql> exit;
Bye
>> root 계정으로 들어가 newuser@localhost 에 권한 부여해줌
grant
select, insert, update, references, delete, create, drop, alter, index, trigger, create view, show view, execute, alter routine, create routine, create temporary tables, lock tables, event, all
on
(데이터베이스명).(테이블명)
to
(계정명)@(localhost, %, ip주소)
;
PS C:\Users\HI> mysql -u root -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 8.0.31 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> grant all on users.* to newuser@localhost;
Query OK, 0 rows affected (0.01 sec)
mysql> exit;
Bye
>>다시 newuser로
PS C:\Users\HI> mysql -u newuser -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 8.0.31 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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 grants;
+------------------------------------------------------------+
| Grants for newuser@localhost |
+------------------------------------------------------------+
| GRANT USAGE ON *.* TO `newuser`@`localhost` |
| GRANT ALL PRIVILEGES ON `users`.* TO `newuser`@`localhost` |
+------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| performance_schema |
| users |
+--------------------+
3 rows in set (0.00 sec)
mysql> use users;
Database changed
mysql> create table users(
-> id varchar(10) primary key,
-> name varchar(20) not null,
-> password varchar(10) not null
-> );
Query OK, 0 rows affected (0.03 sec)
mysql> show tables;
+-----------------+
| Tables_in_users |
+-----------------+
| users |
+-----------------+
1 row in set (0.00 sec)
'STUDY > 다스리는 개발병아리🐥' 카테고리의 다른 글
eclipse에서 .mustache 파일생성 (0) | 2023.03.05 |
---|---|
git repository 합치기 (0) | 2023.03.04 |
정보처리기사 시험정보 (0) | 2023.03.01 |
이클립스에서 html열기 (0) | 2022.11.19 |
2022_09_13 :버튼을 누르면 div내용 보였다가 안보였다가! (0) | 2022.09.13 |