Unable to access sql database with login and password
The error indicates that the SQL Server Service does not have permissions to the folder that the mdf file is located in.

Since SQL Server 2008 the account running SQL Server has by default a minimal permissions set. If you want it to access files in non default directories, you need to explicitly grant access to that location.

In SQL Server 2012 things are complicated even more by Service Isolation.

In 2008 you can just grant access to the folder to the account is setup to start the sql server service. You can find that account in the SQL Server Service Manager.

In SQL 2012 you need to grant access to an account that looks like this: NT SERVICE\MSSQLSERVER or like NT SERVICE\MSSQL$InstanceName.

In your case, as you are using a default instance of SQL Server 2012, granting NT SERVICE\MSSQLSERVER to have write access to the path that contains db.mdf should make things work.