Error 927 - Database Cannot Be Opened While Mirroring Configuration - SQL Server

Mirror - Configuring Endpoints

 
Error 927 - Database Cannot Be Opened While Mirroring Configuration - SQL Server
 

Mirror - DB Properties

 
Error 927 - Database Cannot Be Opened While Mirroring Configuration - SQL Server
 

Mirror - Error 927

 
Database dbname cannot be opened. It is in the middle of a restore. (Microsot SQL Server, Error:927)
 
The error comes when we click on Start Mirroring. 
 
Error 927 - Database Cannot Be Opened While Mirroring Configuration - SQL Server
 
Steps which you will have  followed to get to this point:
  1. Connect the principal server
  2. Take the latest full backup of the database for which mirroring is required
  3. Also take the latest transaction backup of this database
  4. Connect the mirror server (node)
  5. Restore the full and transaction backup on mirror server with "Restore with norecovery" option
  6. After this you come to principal server
  7. In SSMS (SQL server management studio): Connect the instance
  8. In Object explorer, expand the database list
  9. Right click the database (for which we need to configure the mirroring), select the option "Mirror"
  10. On this window, click on configure security
  11. Here you will get the option to configure the witness server, if you have the witness server then click "yes" or if you don't want to configure the security for witness server click "No" then click "Next"
  12. Here you will see the principal server intance window, Listener port number and Endpoint name , then "Next"
  13. Here you will see the Mirror server instance window, click "Connect". Select the mirror server instance then click "Connect"
  14. Automatically mirror listener port and endpoint will be filled, click "Next"
  15. Here you will see the service account window, no need to fill this, click "Next"
  16. Here you will see the complete the wizard window, click "Finish", then "Next"
  17. Then click "Start Mirroring"
  18. And here you will get the error: 927.
Actually this is not an error, this msg tell us that the database, for which you want to configure the mirror, is not fully restored; i.e. it's in the middle of the restore. 
 
First Solution 

For this we need to restore the latest transaction log backup on mirror server/mirror node. Then click on start mirroring again at principal node,  and it will work.
 
Second Solution 
 
If we have restored the full backup and the latest log backup as well and we are still getting error 927, then we need to execute the below-mentioned command as directed:

On Mirror Server run this
 
ALTER DATABASE <Database_Name> SET PARTNER = ‘TCP://<Principal Server>:5022’ 
Exp. : ALTER DATABASE Test SET PARTNER = ‘TCP://Testserver_Principal:5022’

On Principal Server run this
 
ALTER DATABASE <Database_Name> SET PARTNER = ‘TCP://<Mirror Server>:5022’
Exp. ALTER DATABASE Test SET PARTNER = ‘TCP://Testserver_Mirror:5022’
 
After execution of the above commands on respective mirror and principal server, mirroring will be configured successfully.