DROP ENDPOINT Primary_Endpoint_Mirroring

CREATE ENDPOINT Primary_Endpoint_Mirroring
	STATE=STARTED
	AS TCP (LISTENER_PORT=5022)
	FOR DATABASE_MIRRORING (ROLE=ALL)
GO	

select * from sys.database_mirroring_endpoints

GRANT CONNECT ON ENDPOINT::Primary_Endpoint_Mirroring to public 

--***#2***
ALTER DATABASE AdventureWorks
	SET PARTNER = 'TCP://DEMON:5023'
GO

--***#3***
ALTER DATABASE AdventureWorks
	SET WITNESS = 'TCP://DEMON:5024'
GO