sql-serverubuntuaccess-denied

in Ubuntu CREATE FILE encountered operating system error 5(Access is denied.) MSSQL


i followed this article sqlshack link to change the database file default location. i completed all the steps, but after when i'm trying to create DB i encounder below error. i also tried this stackoverlow post but negative response

error :

CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file '/home/user/Templates/sampletable.mdf'.

how can i resolve this issue?


Solution

  • the issue here mssql have access to /Templates dir. But it didn;t have access permission on the parent directories (/home/user), it won't be able to access /Templates even if it has the necessary permissions on /Templates itself.

    To address this, it's essential to verify if the parent directory has access. You can do this by running:
    sudo -u mssql ls /home/user.

    If there's no access, you can rectify this by granting access using:
    sudo chmod o+x /home/users