Database mirroing is High availability feature of SQL Server available from SQL Server 2005 and later,
both the SQL Services must started with the same user name and the user should have Administrator credentials for that domain, as below
Take the full backup and transaction log backup from the primary server and restore it on the secondary server in no recovery mode(in this mode no users can connect to the database).
Open SQL Server Management studio connect to the primary server.
Right click on the database. Go toTask then click mirror
Click on configure security
here if you are using synchronous with automatic fail over then select a witness, witness server can be a SQL Server Express edition, if not simply select NO, in this example i am not using witness server , so we will have manual Failover
assign the port for principal server and check to add in exception in Firewall and in anti Virus.by default 5022 is assigned by SQL Server.
before selecting a port number foryou have to get conneted with the mirror server and thereafter set the port number
after connecting and assigning port number click next
click on Start mirroring, before make sure that FQDN(Fully Qualified Domain Name ) is set, to check FQDN , tou can even give the IP od the server
to have a test the failover just click on the failove button as below
for manual Failover
ALTER DATABASE test SET PARTNER FAILOVER
This query is used to run on Principle/Primary Server, if your Principle server is SHUTDOWN for any reason, then the only thing you have to do is change the Mirrored Server to a Priciple server and the Database has to be accessed by the users.
Log on to your Mirrored server, open SSMS, and write this query
alter database test set partner off
restore database test with recovery
note:- As i have used test as a database, you have to replace your database name with test