I figured it out. I was focused on permission for the folder, not the mdf file. I added myself with full permission to the mdf file and was able to attach it.
Folder lacks permissions to add SQL Server mdf without the log file
I have a new windows server 2019 and SQL Server 2019 installed, and need to add a database by attaching a mdf file without the log file. Its located in a folder different than what SQL Server used during setup so it doesn't have any special permissions assigned to it yet. When I attached the mdf without the log file I get the error:
The log cannot be rebuilt when the primary file is read-only.
I found some info on this here:
https://sqlsailor.com/2011/12/28/file-activation-failure-the-physical-file-name-cprogram-filesmicrosoft-sql-serverpath-may-be-incorrect-the-log-cannot-be-rebuilt-when-the-primary-file-is-read-only/
My default SQL Server data folder has the user/group MSSQLSERVER with full permission assigned to it so I think this is what I need to add to the other folder where I need to locate the new mdf file. When I edit permissions on this folder and try to add the MSSQLSERVER user, its not found in the list or any of the options - so I can't add it and am stuck.
What is the solution to this?
==================================================
New info: As a test I moved the new mdf file to the default database folder where all the other databases are and tried to add it there. Got the same error, so it does not look like a permission issue. Any ideas on how to resolve this?
Thank you.