Commit f8d45b96 authored by 高洋's avatar 高洋

Updates 后端开发/database-init.md

Auto commit by GitBook Editor
parent 2845a5d5
...@@ -12,27 +12,23 @@ max_connections=500 ...@@ -12,27 +12,23 @@ max_connections=500
``` ```
* 用管理员登陆mysql * 用管理员登陆mysql
* 创建数据库hap_dev与hap_prod * 创建数据库hel_dev
```sql ```sql
create schema hap_dev default character set utf8; create schema hel_dev default character set utf8;
create schema hap_prod default character set utf8;
``` ```
* 创建用户hap_dev,并将密码设置为hap_dev * 创建用户hel_dev,并将密码设置为hel_dev
```sql ```sql
CREATE USER hap_dev@'%' IDENTIFIED BY 'hap_dev'; CREATE USER hel_dev@'%' IDENTIFIED BY 'hel_dev';
CREATE USER hap_dev@'localhost' IDENTIFIED BY 'hap_dev'; CREATE USER hel_dev@'localhost' IDENTIFIED BY 'hel_dev';
``` ```
* 将上面新建的hap_dev和hap_prod的权限全部赋予用户hap * 将上面新建的hel_dev权限赋予用户hel
```sql ```sql
GRANT ALL PRIVILEGES ON hap_dev.* TO hap_dev@'%'; GRANT ALL PRIVILEGES ON hel_dev.* TO hel_dev@'%';
GRANT ALL PRIVILEGES ON hap_dev.* TO hap_dev@'localhost'; GRANT ALL PRIVILEGES ON hel_dev.* TO hel_dev@'localhost';
GRANT ALL PRIVILEGES ON hap_prod.* TO hap_dev@'%';
GRANT ALL PRIVILEGES ON hap_prod.* TO hap_dev@'localhost';
flush privileges; flush privileges;
``` ```
# 2. 创建数据库-Oracle # 2. 创建数据库-Oracle
...@@ -40,14 +36,14 @@ max_connections=500 ...@@ -40,14 +36,14 @@ max_connections=500
* 创建表空间 * 创建表空间
```sql ```sql
CREATE BIGFILE TABLESPACE tbs_perm_hap CREATE BIGFILE TABLESPACE tbs_perm_hel
DATAFILE 'tbs_perm_hap.dat' DATAFILE 'tbs_perm_hel.dat'
SIZE 200M SIZE 200M
AUTOEXTEND ON NEXT 20M MAXSIZE 500M; AUTOEXTEND ON NEXT 20M MAXSIZE 500M;
``` ```
```sql ```sql
CREATE TEMPORARY TABLESPACE tbs_temp_hap CREATE TEMPORARY TABLESPACE tbs_temp_hel
TEMPFILE 'tbs_temp_hap.dbf' TEMPFILE 'tbs_temp_hel.dbf'
SIZE 200M SIZE 200M
AUTOEXTEND ON NEXT 20M MAXSIZE 500M; AUTOEXTEND ON NEXT 20M MAXSIZE 500M;
``` ```
...@@ -55,23 +51,23 @@ max_connections=500 ...@@ -55,23 +51,23 @@ max_connections=500
* 创建用户 schema * 创建用户 schema
```sql ```sql
CREATE USER hap_dev CREATE USER hel_dev
IDENTIFIED BY hap_dev IDENTIFIED BY hel_dev
DEFAULT TABLESPACE tbs_perm_hap DEFAULT TABLESPACE tbs_perm_hel
TEMPORARY TABLESPACE tbs_temp_hap TEMPORARY TABLESPACE tbs_temp_hel
QUOTA 200M on tbs_perm_hap; QUOTA 200M on tbs_perm_hel;
``` ```
* 授权 * 授权
```sql ```sql
GRANT create session TO hap_dev; GRANT create session TO hel_dev;
GRANT create table TO hap_dev; GRANT create table TO hel_dev;
GRANT create view TO hap_dev; GRANT create view TO hel_dev;
GRANT create any trigger TO hap_dev; GRANT create any trigger TO hel_dev;
GRANT create any procedure TO hap_dev; GRANT create any procedure TO hel_dev;
GRANT create sequence TO hap_dev; GRANT create sequence TO hel_dev;
GRANT create synonym TO hap_dev; GRANT create synonym TO hel_dev;
``` ```
# 3. 创建数据库-sql server # 3. 创建数据库-sql server
...@@ -79,29 +75,17 @@ max_connections=500 ...@@ -79,29 +75,17 @@ max_connections=500
* 创建数据库 * 创建数据库
```sql ```sql
CREATE DATABASE hap_dev COLLATE Chinese_PRC_CI_AS; CREATE DATABASE hel_dev COLLATE Chinese_PRC_CI_AS;
``` ```
```sql
CREATE DATABASE hap_prod COLLATE Chinese_PRC_CI_AS
```
* 创建用户 hap 并授权 * 创建用户 hel 并授权
```sql ```sql
sp_addlogin 'hap','handhapdev'; sp_addlogin 'hel','hel_dev';
use hap_dev use hel_dev
go
sp_adduser 'hap','hap'
go
sp_addrolemember 'db_owner','hap'
go
```
```sql
use hap_prod
go go
sp_adduser 'hap','hap' sp_adduser 'hel_dev','hel_dev'
go go
sp_addrolemember 'db_owner','hap' sp_addrolemember 'db_owner','hel'
go go
``` ```
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment