Cannot open user default database. Login failed. – Error 4064

If the database that is the default database of a login is dropped, or if the database user is orphaned, the user that is trying to connect to the default database will get the following error:

cannot_open_default_database

Cannot open user default database. Login failed.
Login failed for user ‘User_Name’. (Microsoft SQL Server, Error: 4064)

If the error is related to the problem of having orphaned database users, read related blog post to see how to fix orphaned users in a SQL Server database:
Fixing orphaned users in a SQL Server database

If the database that is the default database of a login is dropped, the login can choose a different database to connect to by clicking on 'Options' in 'Connect to Server' window...

connect_to_server_options

...and by choosing different database instead of 'default':

connect_to_server_options_database

To change the default database for the login to a different database:

USE [master]
GO
ALTER LOGIN [John] WITH DEFAULT_DATABASE = master
GO

change_default_database_for_login

To change the default database for a login using SQL Server Management Studio (SSMS):
Right click on a login, click 'Properties', and choose default database:

change_default_database_for_login_ssms