无法在 Amazon RDS SQL 服务器中附加数据库
Unable to attach database in Amazon RDS SQL Server
我正在尝试分离和附加 AWS RDS 中的数据库。我能够毫无问题地分离数据库。但是当我尝试附加数据库时,我几乎没有遇到错误。
当我第一次运行 attach 命令时,出现以下错误:
Unable to create database: User, group, or role 'sa' already exists in the current database.
当我第二次执行时,我得到这个:
Msg 1802, Level 16, State 7.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5120, Level 16, State 101.
Unable to open the physical file "D:\RDSDBDATA\DATA\DBattachTest.mdf". Operating system error 2: "2(The system cannot find the file specified.)". (Line 6)
请指教
我不确定您要做什么,但您应该使用 backup 和 restore 功能来移动 DB。附加和分离将无法像在传统 SQL 环境中那样工作:RDS 是一项托管服务,您对底层 OS.
的访问权限极其有限
来自AWS docs:
Restoring a Database
To restore your database, you call the rds_restore_database stored procedure.
The following parameters are required:
@restore_db_name – The name of the database to restore.
@s3_arn_to_restore_from – The Amazon S3 bucket that contains the backup file, and the name of the file.
The following parameters are optional:
@kms_master_key_arn – If you encrypted the backup file, the key to use to decrypt the file.
Example Without Encryption
exec msdb.dbo.rds_restore_database
@restore_db_name='database_name',
@s3_arn_to_restore_from='arn:aws:s3:::bucket_name/file_name_and_extension';
Example With Encryption
exec msdb.dbo.rds_restore_database
@restore_db_name='database_name',
@s3_arn_to_restore_from='arn:aws:s3:::bucket_name/file_name_and_extension',
@kms_master_key_arn='arn:aws:kms:region:account-id:key/key-id';
我正在尝试分离和附加 AWS RDS 中的数据库。我能够毫无问题地分离数据库。但是当我尝试附加数据库时,我几乎没有遇到错误。
当我第一次运行 attach 命令时,出现以下错误:
Unable to create database: User, group, or role 'sa' already exists in the current database.
当我第二次执行时,我得到这个:
Msg 1802, Level 16, State 7.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.Msg 5120, Level 16, State 101.
Unable to open the physical file "D:\RDSDBDATA\DATA\DBattachTest.mdf". Operating system error 2: "2(The system cannot find the file specified.)". (Line 6)
请指教
我不确定您要做什么,但您应该使用 backup 和 restore 功能来移动 DB。附加和分离将无法像在传统 SQL 环境中那样工作:RDS 是一项托管服务,您对底层 OS.
的访问权限极其有限来自AWS docs:
Restoring a Database
To restore your database, you call the rds_restore_database stored procedure.
The following parameters are required:
@restore_db_name – The name of the database to restore.
@s3_arn_to_restore_from – The Amazon S3 bucket that contains the backup file, and the name of the file.
The following parameters are optional:
@kms_master_key_arn – If you encrypted the backup file, the key to use to decrypt the file.
Example Without Encryption
exec msdb.dbo.rds_restore_database
@restore_db_name='database_name',
@s3_arn_to_restore_from='arn:aws:s3:::bucket_name/file_name_and_extension';
Example With Encryption
exec msdb.dbo.rds_restore_database
@restore_db_name='database_name',
@s3_arn_to_restore_from='arn:aws:s3:::bucket_name/file_name_and_extension',
@kms_master_key_arn='arn:aws:kms:region:account-id:key/key-id';