I upgraded my ubuntu server from 20.04 to 22.04 and after the upgrade MSSQL stopped working cause Microsoft doesn't support this version of Ubuntu yet. I lost the backup file of the database(Cause I had a copy in another computer which I don't have currently access to), but I still have the mdfs, logs, .conf and secrets files and folders inside mssql data. I reinstalled MSSQL on a docker container and I thought to take these mdf and ldf files(inside data folder) and replace them on docker. I changed the ownership of files, but still getting error access denied. How I can get this working? The error I get:
2022-08-29 12:23:36.25 spid20s Starting up database 'master'.
2022-08-29 12:23:36.27 spid20s Error: 17204, Severity: 16, State: 1.
2022-08-29 12:23:36.27 spid20s FCB::Open failed: Could not open file /var/opt/mssql/data/master.mdf for file number 1. OS error: 5(Access is denied.).
2022-08-29 12:23:36.28 spid20s Error: 5120, Severity: 16, State: 101.
2022-08-29 12:23:36.28 spid20s Unable to open the physical file "/var/opt/mssql/data/master.mdf". Operating system error 5: "5(Access is denied.)".
2022-08-29 12:23:36.31 spid20s Error: 17204, Severity: 16, State: 1.
2022-08-29 12:23:36.31 spid20s FCB::Open failed: Could not open file /var/opt/mssql/data/mastlog.ldf for file number 2. OS error: 5(Access is denied.).
2022-08-29 12:23:36.32 spid20s Error: 5120, Severity: 16, State: 101.
2022-08-29 12:23:36.32 spid20s Unable to open the physical file "/var/opt/mssql/data/mastlog.ldf". Operating system error 5: "5(Access is denied.)".
CodePudding user response:
If you have the .mdf (.ndf if applicable) and .ldf files you can create a database from these file using the for attach
clause or the sp_attach_db system procedure.
See the full documentation
CodePudding user response:
The problem was that I didn't check for hidden folders. So, I just removed everything inside the /var/opt/mssql/ folder that includes:
- .system/ - which I didn't see before
- data/
- secrets/
- log/
- mssql.conf
And I replaced them with the corresponding files and folders, by switching also the ownership of every file and folder to the right user (In my case of docker it was mssql).