Updated on 2023-01-05 GMT+08:00

Checking Whether the Destination Database User Has Sufficient Permissions

MySQL Migration

Table 1 Checking whether the destination database user has sufficient permissions

Check Item

Whether the destination database user has sufficient permissions

Description

Check whether the destination database user permissions meet the migration requirements. If the permissions are insufficient, the migration will fail.

Failure Cause and Handling Suggestion

Failure cause: The destination database user must have the following permissions: SELECT, CREATE, DROP, DELETE, INSERT, UPDATE, INDEX, EVENT, CREATE VIEW, CREATE ROUTINE, TRIGGER, and WITH GRANT OPTION. If the destination database version is in the range from 8.0.14 to 8.0.18, the SESSION_VARIABLES_ADMIN permission is required.

Handling suggestion: Check whether the destination database user permissions meet the migration requirements.

Failure cause: Insufficient user permissions

Handling suggestion: Check whether the database user permissions meet the migration requirements.

PostgreSQL Synchronization

Table 2 Checking whether the destination database user has sufficient permissions

Check Item

Whether the destination database user has sufficient permissions

Description

Different permissions are granted based on the scope of objects to be synchronized.

  • Database-level synchronization objects:

    The CREATEDB permission and the root user or a member of root are required (only in special scenarios). For details, see the following description.

  • Table-level synchronization object:

    To synchronize databases: The CREATEDB permission is required.

    To synchronize schemas, the CONNECT and CREATE permissions for the database that contains the schema are required.

    To synchronize objects in a schema: The CONNECT permission for the database that contains the schema, the USAGE permission for the schema that contains the object, and CREATE permission for the schema that contains the object are required.

  • Synchronization user: The CREATEROLE permission is required.
  • Permission to synchronize objects: The default privilege is the default value and cannot be modified. Otherwise, the object permissions of the destination database may be different from those of the source database.

Failure Cause and Handling Suggestion

Failure cause: The destination database user must have the CREATEDB permission.

Handling suggestion: Grant the destination database user the CREATEDB permission.

alter role username with createdb;

Failure cause: The user does not have the USAGE permission for schemas.

Handling suggestion: Grant the destination database user the CREATEDB permission.

grant usage on schema schemaname to username;

Failure cause: The user does not have the permission to create tales.

Handling suggestion: Grant the destination database user the permission to create tables.

grant create on schema schemaname to username;

Failure cause: The user does not have the permission to create schemas.

Handling suggestion: Grant the destination database user the permission to create schemas.

grant create on database to username;

MongoDB Migration

Table 3 Checking whether the destination database user has sufficient permissions

Check Item

Whether the destination database user has sufficient permissions

Description

Check whether the destination database user permissions meet the migration requirements. If the permissions are insufficient, the migration will fail.

Failure Cause and Handling Suggestion

Failure cause: This item cannot be checked because the destination database fails to be connected.

Handling suggestion: Check whether the destination database is connected.

Failure cause: The destination database user must have the dbAdminAnyDatabase permission for the admin database, the read permission for the config database, and the readWrite permission for the destination database.

Handling suggestion: Run the following statement to grant permissions to the destination database user.

db.grantRolesToUser("Username",[{role:"dbAdminAnyDatabase",db:"admin"}, {role:"read",db:"config"}, {role:"readWriteAnyDatabase",db:"admin"}])

Failure cause: The destination database user must have the readWrite permission for the databases to be migrated.

Handling suggestion: Run the following statement to grant permissions to the destination database user.

db.grantRolesToUser("Username",[{role:"readWriteAnyDatabase",db:"admin"}])

Failure cause: The destination database user must have the read permission for the config database.

Handling suggestion: Run the following statement to grant permissions to the destination database user.

db.grantRolesToUser("Username",[{role:"read",db:"config"}])

Failure cause: The destination database user must have the dbAdminAnyDatabase permission for the admin database.

Handling suggestion: Run the following statement to grant permissions to the destination database user.

db.grantRolesToUser("Username",[{role:"dbAdminAnyDatabase",db:"admin"}])

Failure cause: The destination database user must have the clusterManager permission for the admin database.

Handling suggestion: Run the following statement to grant permissions to the destination database user.

db.grantRolesToUser("Username",[{role:"clusterManager",db:"admin"}])