Skip to content

Commit 1cc3192

Browse files
committed
repl/mt database
1 parent 4020800 commit 1cc3192

File tree

6 files changed

+165
-14
lines changed

6 files changed

+165
-14
lines changed

pages/clustering/replication.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,42 @@ When dropping a database used on a REPLICA, the REPLICA will receive the command
145145
and will partially drop the database. It will hide the database and prevent any new
146146
usage. Once all clients have released the database, it will be deleted entirely.
147147

148+
## Replication queries and the memgraph database
149+
150+
Recent changes to Memgraph have modified how replication queries are executed. Replication queries (such as `REGISTER REPLICA`, `SHOW REPLICAS`, `DROP REPLICA`, etc.) now target the default "memgraph" database and require access to it.
151+
152+
### Requirements for replication queries
153+
154+
To execute replication queries, users must have:
155+
1. The `REPLICATION` privilege
156+
2. Access to the default "memgraph" database
157+
158+
### Impact on multi-tenant environments
159+
160+
In multi-tenant environments where users might not have access to the "memgraph" database, replication management operations will fail. This reinforces the recommendation to treat the "memgraph" database as an administrative/system database.
161+
162+
#### Example: Admin user with replication privileges
163+
164+
```cypher
165+
-- Create admin role with replication privileges
166+
CREATE ROLE replication_admin;
167+
GRANT REPLICATION TO replication_admin;
168+
GRANT DATABASE memgraph TO replication_admin;
169+
170+
-- Create user with replication admin role
171+
CREATE USER repl_admin IDENTIFIED BY 'admin_password';
172+
SET ROLE FOR repl_admin TO replication_admin;
173+
```
174+
175+
In this setup, `repl_admin` can:
176+
- Execute all replication queries (`REGISTER REPLICA`, `SHOW REPLICAS`, etc.)
177+
- Access the "memgraph" database for administrative operations
178+
- Manage the replication cluster configuration
179+
180+
### Best practice
181+
182+
For replication management, ensure that users who need to perform replication operations have both the `REPLICATION` privilege and access to the "memgraph" database. This aligns with the overall recommendation to treat the "memgraph" database as an administrative database in multi-tenant environments.
183+
148184
## Running multiple instances
149185

150186
When running multiple instances, each on its own machine, run Memgraph as you

pages/database-management/authentication-and-authorization.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ Authentication and authorization queries (such as `CREATE USER`, `CREATE ROLE`,
2121

2222
In addition to the `AUTH` privilege, users must also have access to the default "memgraph" database to execute authentication and authorization queries. This requirement applies even when the user is working in other databases within a multi-tenant environment.
2323

24+
### Replication and multi-database queries
25+
26+
Replication queries (such as `REGISTER REPLICA`, `SHOW REPLICAS`, `DROP REPLICA`, etc.) and multi-database queries (such as `SHOW DATABASES`, `CREATE DATABASE`, `DROP DATABASE`, etc.) also now target the "memgraph" database and require access to it.
27+
2428
### Multi-tenant recommendations
2529

2630
For multi-tenant environments, we recommend:
2731
- Treating the default "memgraph" database as an administrative/system database
2832
- Restricting access to the "memgraph" database to privileged users only
2933
- Storing application data in tenant-specific databases
30-
- Ensuring users who need to perform authentication operations have appropriate access
34+
- Ensuring users who need to perform authentication, replication, or multi-database operations have appropriate access
3135

32-
For detailed information about these requirements and best practices, see the [Role-based access control](/database-management/authentication-and-authorization/role-based-access-control#authentication-and-authorization-requirements) and [Multi-tenancy](/database-management/multi-tenancy#default-database-best-practices) documentation.
36+
For detailed information about these requirements and best practices, see the [Role-based access control](/database-management/authentication-and-authorization/role-based-access-control#authentication-and-authorization-requirements), [Multi-tenancy](/database-management/multi-tenancy#default-database-best-practices), and [Replication](/clustering/replication#replication-queries-and-the-memgraph-database) documentation.
3337

3438
## [Users](/database-management/authentication-and-authorization/users)
3539

pages/database-management/authentication-and-authorization/multiple-roles.mdx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ Authentication and authorization queries (such as `CREATE USER`, `CREATE ROLE`,
2929

3030
In addition to the `AUTH` privilege, users must also have access to the default "memgraph" database to execute authentication and authorization queries. This requirement applies even when the user is working in other databases within a multi-tenant environment.
3131

32+
### Replication and multi-database queries
33+
34+
Replication queries (such as `REGISTER REPLICA`, `SHOW REPLICAS`, `DROP REPLICA`, etc.) and multi-database queries (such as `SHOW DATABASES`, `CREATE DATABASE`, `DROP DATABASE`, etc.) also now target the "memgraph" database and require access to it.
35+
3236
<Callout type="warning">
33-
**Multi-tenant environments**: This requirement is only a concern in multi-tenant environments where users have access to databases other than the default "memgraph" database. In single-database deployments, this requirement is automatically satisfied.
37+
**Multi-tenant environments**: These requirements are only a concern in multi-tenant environments where users have access to databases other than the default "memgraph" database. In single-database deployments, these requirements are automatically satisfied.
3438
</Callout>
3539

3640
### Impact on multi-tenant role management
3741

38-
When using multi-tenant roles, ensure that users who need to perform authentication and authorization operations have:
39-
1. The `AUTH` privilege granted to their roles
42+
When using multi-tenant roles, ensure that users who need to perform authentication, authorization, replication, or multi-database operations have:
43+
1. The appropriate privileges (`AUTH`, `REPLICATION`, `MULTI_DATABASE_USE`, `MULTI_DATABASE_EDIT`)
4044
2. Access to the default "memgraph" database
4145
3. Appropriate role assignments for the "memgraph" database
4246

@@ -67,6 +71,7 @@ SET ROLE FOR admin_user TO tenant2_admin ON tenant2_db;
6771

6872
In this setup, `admin_user` can:
6973
- Perform authentication/authorization operations when connected to the "memgraph" database
74+
- Execute replication and multi-database queries when connected to the "memgraph" database
7075
- Manage tenant1_db data when connected to tenant1_db
7176
- Manage tenant2_db data when connected to tenant2_db
7277

@@ -342,5 +347,7 @@ SET ROLE multi_db_role FOR user1 ON db2;
342347
6. **Use deny sparingly**: Remember that deny takes precedence over grant across all databases
343348
7. **Treat memgraph database as admin database**: In multi-tenant environments, restrict access to the default "memgraph" database to privileged users only
344349
8. **Ensure AUTH privilege access**: Users who need to perform authentication/authorization operations must have both the `AUTH` privilege and access to the "memgraph" database
345-
9. **Separate application data**: Store all application data in tenant-specific databases, not in the default "memgraph" database
346-
10. **Plan for authentication operations**: Design your role structure to ensure that users who need to manage users and roles have appropriate access to the "memgraph" database
350+
9. **Ensure replication privilege access**: Users who need to perform replication operations must have both the `REPLICATION` privilege and access to the "memgraph" database
351+
10. **Ensure multi-database privilege access**: Users who need to perform multi-database operations must have the appropriate privileges (`MULTI_DATABASE_USE`, `MULTI_DATABASE_EDIT`) and access to the "memgraph" database
352+
11. **Separate application data**: Store all application data in tenant-specific databases, not in the default "memgraph" database
353+
12. **Plan for administrative operations**: Design your role structure to ensure that users who need to manage users, roles, replication, or multi-database operations have appropriate access to the "memgraph" database

pages/database-management/authentication-and-authorization/role-based-access-control.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,25 @@ Authentication and authorization queries (such as `CREATE USER`, `CREATE ROLE`,
133133

134134
In addition to the `AUTH` privilege, users must also have access to the default "memgraph" database to execute authentication and authorization queries. This requirement applies even when the user is working in other databases within a multi-tenant environment.
135135

136+
### Replication and multi-database queries
137+
138+
Replication queries (such as `REGISTER REPLICA`, `SHOW REPLICAS`, `DROP REPLICA`, etc.) and multi-database queries (such as `SHOW DATABASES`, `CREATE DATABASE`, `DROP DATABASE`, etc.) also now target the "memgraph" database and require access to it.
139+
140+
To execute these queries, users must have:
141+
- The appropriate privileges (`REPLICATION`, `MULTI_DATABASE_USE`, `MULTI_DATABASE_EDIT`)
142+
- Access to the default "memgraph" database
143+
136144
<Callout type="warning">
137-
**Multi-tenant environments**: This requirement is only a concern in multi-tenant environments where users have access to databases other than the default "memgraph" database. In single-database deployments, this requirement is automatically satisfied.
145+
**Multi-tenant environments**: These requirements are only a concern in multi-tenant environments where users have access to databases other than the default "memgraph" database. In single-database deployments, these requirements are automatically satisfied.
138146
</Callout>
139147

140148
### Recommended approach for multi-tenant environments
141149

142150
In multi-tenant environments, we recommend treating the default "memgraph" database as an administrative/system database rather than storing application data in it. This approach provides better security and isolation:
143151

144-
1. **Restrict access to the memgraph database**: Only grant access to privileged users who need to perform authentication and authorization operations
152+
1. **Restrict access to the memgraph database**: Only grant access to privileged users who need to perform authentication, authorization, replication, or multi-database management operations
145153
2. **Use tenant-specific databases**: Store application data in dedicated tenant databases rather than the default database
146-
3. **Separate administrative functions**: Keep user management and system administration separate from application data
154+
3. **Separate administrative functions**: Keep user management, system administration, replication management, and multi-database management separate from application data
147155

148156
#### Example setup for multi-tenant environments
149157

@@ -177,7 +185,7 @@ SET ROLE FOR tenant2_user_account TO tenant2_user;
177185
```
178186

179187
In this setup:
180-
- `admin_user` has access to the "memgraph" database and can perform all authentication/authorization operations
188+
- `admin_user` has access to the "memgraph" database and can perform all authentication/authorization, replication, and multi-database operations
181189
- `tenant1_user_account` and `tenant2_user_account` can only access their respective tenant databases
182190
- Application data is stored in tenant-specific databases, not in the default "memgraph" database
183191

pages/database-management/multi-tenancy.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ In multi-tenant environments, we recommend treating the default "memgraph" datab
2626

2727
#### Why treat memgraph as an admin database?
2828

29-
Recent changes to Memgraph require that users have both the `AUTH` privilege and access to the default "memgraph" database to execute authentication and authorization queries. This requirement affects multi-tenant environments where users might have access to other databases but not the default one.
29+
Recent changes to Memgraph require that users have both the `AUTH` privilege and access to the default "memgraph" database to execute authentication and authorization queries. Additionally, replication queries (such as `REGISTER REPLICA`, `SHOW REPLICAS`, etc.) and multi-database queries (such as `SHOW DATABASES`, `CREATE DATABASE`, etc.) also now target the "memgraph" database and require access to it. This requirement affects multi-tenant environments where users might have access to other databases but not the default one.
3030

3131
#### Recommended setup
3232

3333
1. **Restrict memgraph database access**: Only grant access to the "memgraph" database to privileged users who need to perform system administration tasks
3434
2. **Use tenant-specific databases**: Store all application data in dedicated tenant databases
35-
3. **Separate concerns**: Keep user management, role management, and system administration separate from application data
35+
3. **Separate concerns**: Keep user management, role management, system administration, replication management, and multi-database management separate from application data
3636

3737
#### Example configuration
3838

@@ -74,7 +74,7 @@ SET ROLE FOR tenant2_regular_user TO tenant2_user;
7474
```
7575

7676
In this configuration:
77-
- `system_admin_user` can perform all authentication/authorization operations and has access to the "memgraph" database
77+
- `system_admin_user` can perform all authentication/authorization, replication, and multi-database operations and has access to the "memgraph" database
7878
- Tenant users can only access their respective tenant databases
7979
- Application data is completely isolated in tenant-specific databases
8080
- The "memgraph" database serves purely as an administrative database
@@ -140,6 +140,42 @@ Access to all databases can be granted or revoked using wildcards:
140140
`GRANT DATABASE * TO user;`, `DENY DATABASE * TO user;` or
141141
`REVOKE DATABASE * FROM user;`.
142142

143+
### Multi-database queries and the memgraph database
144+
145+
Recent changes to Memgraph have modified how multi-database queries are executed. Multi-database queries (such as `SHOW DATABASES`, `CREATE DATABASE`, `DROP DATABASE`, etc.) now target the default "memgraph" database and require access to it.
146+
147+
#### Requirements for multi-database queries
148+
149+
To execute multi-database queries, users must have:
150+
1. The appropriate multi-database privileges (`MULTI_DATABASE_USE`, `MULTI_DATABASE_EDIT`)
151+
2. Access to the default "memgraph" database
152+
153+
#### Impact on multi-tenant environments
154+
155+
In multi-tenant environments where users might not have access to the "memgraph" database, multi-database management operations will fail. This reinforces the recommendation to treat the "memgraph" database as an administrative/system database.
156+
157+
#### Example: Admin user with multi-database privileges
158+
159+
```cypher
160+
-- Create admin role with multi-database privileges
161+
CREATE ROLE multi_db_admin;
162+
GRANT MULTI_DATABASE_USE, MULTI_DATABASE_EDIT TO multi_db_admin;
163+
GRANT DATABASE memgraph TO multi_db_admin;
164+
165+
-- Create user with multi-database admin role
166+
CREATE USER db_admin IDENTIFIED BY 'admin_password';
167+
SET ROLE FOR db_admin TO multi_db_admin;
168+
```
169+
170+
In this setup, `db_admin` can:
171+
- Execute all multi-database queries (`SHOW DATABASES`, `CREATE DATABASE`, etc.)
172+
- Access the "memgraph" database for administrative operations
173+
- Manage the multi-tenant database configuration
174+
175+
#### Best practice
176+
177+
For multi-database management, ensure that users who need to perform multi-database operations have both the appropriate multi-database privileges and access to the "memgraph" database. This aligns with the overall recommendation to treat the "memgraph" database as an administrative database in multi-tenant environments.
178+
143179
### Additional multi-tenant privileges
144180

145181
Administrators manage multi-tenant privileges with:

pages/help-center/errors/auth.mdx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,65 @@ GRANT DATABASE memgraph TO role_name;
7373

7474
In multi-tenant environments, we recommend treating the "memgraph" database as an administrative/system database and restricting access to privileged users only. See the [multi-tenancy documentation](/database-management/multi-tenancy#default-database-best-practices) for recommended setup patterns.
7575

76+
## User doesn't have REPLICATION privilege
77+
78+
This error occurs when a user attempts to execute replication queries (such as `REGISTER REPLICA`, `SHOW REPLICAS`, `DROP REPLICA`, etc.) without the required `REPLICATION` privilege.
79+
80+
### Solution
81+
82+
Grant the `REPLICATION` privilege to the user or their role:
83+
84+
```cypher
85+
-- Grant REPLICATION privilege to a user
86+
GRANT REPLICATION TO username;
87+
88+
-- Grant REPLICATION privilege to a role
89+
GRANT REPLICATION TO role_name;
90+
```
91+
92+
### Multi-tenant environments
93+
94+
In multi-tenant environments, users must also have access to the default "memgraph" database to execute replication queries. See the [replication documentation](/clustering/replication#replication-queries-and-the-memgraph-database) for more details.
95+
96+
## User doesn't have MULTI_DATABASE_USE privilege [#error-6]
97+
98+
This error occurs when a user attempts to execute multi-database queries (such as `SHOW DATABASES`, `USE DATABASE`) without the required `MULTI_DATABASE_USE` privilege.
99+
100+
### Solution
101+
102+
Grant the `MULTI_DATABASE_USE` privilege to the user or their role:
103+
104+
```cypher
105+
-- Grant MULTI_DATABASE_USE privilege to a user
106+
GRANT MULTI_DATABASE_USE TO username;
107+
108+
-- Grant MULTI_DATABASE_USE privilege to a role
109+
GRANT MULTI_DATABASE_USE TO role_name;
110+
```
111+
112+
### Multi-tenant environments
113+
114+
In multi-tenant environments, users must also have access to the default "memgraph" database to execute multi-database queries. See the [multi-tenancy documentation](/database-management/multi-tenancy#multi-database-queries-and-the-memgraph-database) for more details.
115+
116+
## User doesn't have MULTI_DATABASE_EDIT privilege [#error-7]
117+
118+
This error occurs when a user attempts to execute multi-database management queries (such as `CREATE DATABASE`, `DROP DATABASE`) without the required `MULTI_DATABASE_EDIT` privilege.
119+
120+
### Solution
121+
122+
Grant the `MULTI_DATABASE_EDIT` privilege to the user or their role:
123+
124+
```cypher
125+
-- Grant MULTI_DATABASE_EDIT privilege to a user
126+
GRANT MULTI_DATABASE_EDIT TO username;
127+
128+
-- Grant MULTI_DATABASE_EDIT privilege to a role
129+
GRANT MULTI_DATABASE_EDIT TO role_name;
130+
```
131+
132+
### Multi-tenant environments
133+
134+
In multi-tenant environments, users must also have access to the default "memgraph" database to execute multi-database management queries. See the [multi-tenancy documentation](/database-management/multi-tenancy#multi-database-queries-and-the-memgraph-database) for more details.
135+
76136

77137
<CommunityLinks/>

0 commit comments

Comments
 (0)