SQL Server Error 1460: Fix Database Already Configured
In this article
SQL Server Error 1460 occurs when you attempt to add a database to a mirroring session or a availability group, but the database is already associated with a mirroring configuration. To resolve this, you must remove the existing mirroring configuration from both the principal and mirror servers before you can re-establish the connection or move the database to a new configuration. This typically happens after a failed failover, an improper shutdown of the mirroring session, or when attempting to reuse a database snapshot that was previously mirrored.
What You'll Need
- SQL Server Management Studio (SSMS) installed on a workstation with access to the instances.
- Administrative privileges (sysadmin role) on both the principal and mirror SQL Server instances.
- The exact names of the databases involved in the mirroring or availability group setup.
- A current backup of the database to ensure data safety before modifying system configurations.
Step-by-Step
- Identify the Current Status: Open SQL Server Management Studio and connect to the principal server. Right-click the database in question, navigate to Tasks, and select Mirroring. Note whether the status is listed as "Disconnected," "Synchronizing," or "Synchronized." If the mirroring window is inaccessible or throws an error, you will need to use T-SQL commands to inspect the state.
- Remove Mirroring on the Principal Server: To clear the configuration that is causing Error 1460, you must first tell the principal server to stop mirroring. Open a New Query window and execute the following command:
ALTER DATABASE [YourDatabaseName] SET PARTNER OFF;Replace[YourDatabaseName]with the actual name of your database. This command breaks the link between the principal and the mirror, returning the database to a standalone state. - Remove Mirroring on the Mirror Server: Connect to the mirror instance via SSMS. Because the mirror database is typically in a "Restoring" or "Non-operational" state, you cannot simply use the GUI. Execute the same command:
ALTER DATABASE [YourDatabaseName] SET PARTNER OFF;. If the mirror server does not recognize the command because it believes it is not the principal, you may need to drop the database on the mirror server entirely if you intend to re-initialize it from a fresh backup. - Verify the Removal: Run a query against
sys.database_mirroringon both servers. Themirroring_state_descshould no longer indicate an active or pending mirroring session. If the database on the mirror server is still in a restoring state, it is now a "detached" mirror and is ready to be repurposed or deleted. - Clean Up Orphaned Configurations: In some cases, the metadata persists in the system catalogs. If the error persists after running the SET PARTNER OFF command, restart the SQL Server services on both instances. This clears the memory cache and forces the engine to re-read the configuration from the disk, ensuring that the "already configured" flag is cleared.
- Re-establish the Mirroring/Availability Group: Now that the conflict is resolved, you can begin the setup process again. Start by taking a full backup and a transaction log backup of the principal database. Restore these onto the mirror server using the
NORECOVERYoption. Once the mirror is in the restoring state, execute theCREATE MIRRORcommand on the mirror server, followed by theSET PARTNERcommand on the principal server.
Common Mistakes
One of the most frequent errors is attempting to fix the issue only on the principal server. Because mirroring is a distributed configuration, the mirror server often retains a "ghost" configuration that prevents a new session from starting. You must explicitly clear the partner relationship on both ends of the connection.
Another common mistake is trying to force the database online on the mirror server using RESTORE DATABASE ... WITH RECOVERY before removing the mirroring configuration. Doing this changes the database state in a way that can make the SET PARTNER OFF command fail, as the database is no longer in the expected mirroring state. Always remove the partner relationship while the mirror is still in the restoring state if possible.
Users also frequently forget to check the SQL Server Agent. If there are automated scripts or jobs attempting to restart mirroring in the background, they may re-trigger the configuration before you have a chance to clean it up, leading to a loop where Error 1460 reappears immediately after you think you have fixed it.
Tips
When managing mirroring, always use a dedicated service account for the SQL Server instances. If the account password changes or the account is locked, the mirroring session may drop, but the configuration remains. This often leads to Error 1460 when administrators try to "fix" the connection by adding the database again without first removing the broken configuration.
Keep a script of your mirroring endpoints and port configurations. Error 1460 is about the database configuration, but once that is solved, connection issues often arise due to firewall rules or endpoint mismatches. Having your sys.endpoints query results handy will save time during the re-configuration phase.
Consider migrating from Database Mirroring to Always On Availability Groups if you are using a modern version of SQL Server. Availability Groups provide more flexibility and better management tools in SSMS, which reduces the likelihood of encountering low-level configuration errors like 1460.
Troubleshooting
If the ALTER DATABASE ... SET PARTNER OFF command fails with an error stating that the database is not mirrored, but you still receive Error 1460 when trying to configure it, the issue is likely a metadata mismatch. In this scenario, the safest path is to drop the database on the mirror server. Note that dropping the database on the mirror server deletes all data on that specific instance; however, since the principal server holds the primary copy, your data remains safe. After dropping the mirror database, restart the SQL Server service on the mirror instance and try the setup again.
If you encounter a "Permission Denied" error while trying to clear the configuration, ensure that your login is mapped to the sysadmin fixed server role on both instances. Mirroring operations require high-level permissions because they modify system-level endpoints and database states.
In rare cases, the database may be stuck in a "Synchronizing" state that refuses to respond to T-SQL commands. If the server is unresponsive to the SET PARTNER OFF command, try taking the database offline first using ALTER DATABASE [YourDatabaseName] SET OFFLINE WITH ROLLBACK IMMEDIATE, then attempt the partner removal again. If it still fails, a full restart of the Windows Server hosting the SQL instance is the final resort to clear locked system threads.
Frequently Asked Questions
Does removing the mirroring configuration delete my data?
No, running SET PARTNER OFF does not delete the data within the databases. It simply breaks the synchronization link between the two servers. The principal database remains online and accessible, and the mirror database remains in a restoring state until you either recover it or drop it.
Can I fix Error 1460 using the SSMS GUI?
While you can sometimes use the Mirroring properties window, T-SQL is significantly more reliable for resolving Error 1460. The GUI often fails to update the status in real-time or may throw a generic error that doesn't explain why the configuration is stuck, whereas T-SQL provides direct control over the partner state.
Why did this error happen if I never set up mirroring?
This can happen if you restored a database from a backup that was previously part of a mirroring session on a different server. The database carries metadata indicating it was mirrored. You must clear this metadata using the SET PARTNER OFF command before you can use the database in a new mirroring or availability group setup.
Is this error related to the SQL Server Agent?
Not directly, but the SQL Server Agent can exacerbate the problem. If you have a job that monitors mirroring and attempts to automatically re-establish it, it may conflict with your manual attempts to clear the configuration, making it seem like the error is returning on its own.
Will this affect my users' access to the database?
Removing mirroring from the principal server does not disconnect users or take the primary database offline. However, any users who were relying on a read-only mirror (if configured) will lose access to that secondary copy until the mirroring is successfully re-established.