Attach a sql database running SQL Server on EC2
Dec 15, 2020 Janaki Mahapatra, Installation
Here are the steps to attach a SQL db
- Copy the database data and log files to /var/opt/mssql/data
- Run chmod 777 for the data and log file
- Connect to Sql Server using sqlcmd command line: sqlcmd -S localhost -U sa
- Run the attach T-SQL script:
CREATE DATABASE [db_name] ON PRIMARY (FILENAME=N'/var/opt/mssql/data/your_db_Data.mdf')
LOG ON (FILENAME=N'/var/opt/mssql/data/your_db_Log.ldf') FOR ATTACH;
GO