Lansweeper data, reports and settings are stored in a database. Your database is hosted in either the Microsoft SQL Compact, Microsoft SQL LocalDB or Microsoft SQL Server database server. If you install Lansweeper under SQL LocalDB or SQL Server, the installer automatically creates a SQL user called "lansweeperuser". This user is used by the Lansweeper scanning service and web console to connect to the database.
If lansweeperuser gets corrupted, or has its password changed without an accompanying update of the Lansweeper configuration files, the service and console will no longer be able to connect to the database and you may see errors like the one below. The error below indicates that, even though Lansweeper is able to find the SQL instance hosting the lansweeperdb database, it is unable to access the database with the lansweeperuser account. It's important to note that this does not point to database corruption or an issue with the database itself. It simply indicates that the database cannot be accessed to read or write information. To resolve this issue, lansweeperuser needs to be reset.
Cannot connect to database, check your config file, service will be stopped. Login failed for user 'lansweeperuser'.
To reset lansweeperuser and have the service and console successfully connect to the database again, follow these steps:
-
Stop the Lansweeper Server service in Windows Services
-
Stop your web server service in Windows Services. Your web server service is either IIS Express or World Wide Web Publishing Service (IIS).
-
Stop the Lansweeper Auto-update service in Windows Services.
-
Log into SQL Server Management Studio. If SQL Server Management Studio isn't installed on your Lansweeper server, we recommend downloading it online.
If your database is hosted in SQL LocalDB, the SQL instance name you need to submit in Management Studio is
(localdb)\.\LSInstanceand you must log in on your Lansweeper server itself with the Windows user that initially installed Lansweeper. If your database is hosted in SQL Server, you would have configured your SQL instance name and password when you installed SQL Server. -
If your database server is SQL Server, make sure your SQL instance is configured for mixed (Windows and SQL) authentication. If your database server is SQL LocalDB, your SQL instance should already be configured for mixed authentication by default.
-
Right-click your SQL instance name in SQL Server Management Studio.
-
Select the Properties menu item.
-
Select the Security tab in the resulting pop-up, and tick SQL Server and Windows Authentication mode.
-
Right-click your SQL instance name and select Restart.
-
-
Execute the script below in SQL Server Management Studio to reset the lansweeperuser SQL user used by the Lansweeper service and web console to connect to the database. Replace 'lansweeperuserpassword' with the password you'd like to use for the lansweeperuser database user, leaving the single quotes in the script.
This script requires SQL Server 2016 or later. If you're on SQL Server 2014, see the FAQ below for a compatible version.
/* Makes sure there are no objects in the lansweeperuser schema, so the lansweeperuser SQL user can be reset */ USE lansweeperdb GO IF EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'lansweeperuser') BEGIN DECLARE c_ALTSCHEMA CURSOR FOR SELECT 'ALTER SCHEMA dbo TRANSFER lansweeperuser.' + name + ';' FROM sys.objects WHERE SCHEMA_NAME(SCHEMA_ID) = 'lansweeperuser' DECLARE @SQLStmt NVARCHAR(200) OPEN c_ALTSCHEMA FETCH NEXT FROM c_ALTSCHEMA INTO @SQLStmt WHILE @@FETCH_STATUS = 0 BEGIN EXEC(@SQLStmt) FETCH NEXT FROM c_ALTSCHEMA INTO @SQLStmt END CLOSE c_ALTSCHEMA DEALLOCATE c_ALTSCHEMA END GO /* Resets the lansweeperuser SQL user */ USE lansweeperdb GO DROP SCHEMA IF EXISTS lansweeperuser GO DROP USER IF EXISTS lansweeperuser GO USE MASTER GO DROP LOGIN IF EXISTS lansweeperuser GO CREATE LOGIN lansweeperuser WITH PASSWORD = 'lansweeperuserpassword', CHECK_POLICY = OFF, DEFAULT_DATABASE = lansweeperdb, DEFAULT_LANGUAGE = [English] GO USE lansweeperdb GO CREATE USER lansweeperuser FOR LOGIN lansweeperuser GO ALTER ROLE [db_owner] ADD MEMBER lansweeperuser GO -
Run the ConfigEditor.exe tool, found at
Program Files (x86)\Lansweeper\Tools\ConfigEditor.exeon the servers hosting your Lansweeper Server service and web console. -
Click through any warnings the tool may be giving you about your password being incorrect.
-
Select the Password field and select Edit.
-
Submit the same password you previously used in the database script and select Save.
-
If the ConfigEditor tool has multiple tabs due to your server hosting multiple Lansweeper components, select the other tabs, click through any warnings and repeat the password changing process.
-
Select Save.
-
Restart the Lansweeper Server, web server, and Lansweeper Auto-update services in Windows Services.
FAQ
What if I'm on SQL Server 2014?
The script in step 6 needs SQL Server 2016 or later, since it relies on CREATE LOGIN and the DROP ... IF EXISTS syntax. On SQL Server 2014, use this version instead. Replace 'lansweeperuserpassword' with the password you'd like to use for the lansweeperuser database user, leaving the single quotes in the script.
/* Makes sure there are no objects in the lansweeperuser schema, so the lansweeperuser SQL user can be reset */
USE lansweeperdb
GO
IF EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'lansweeperuser')
BEGIN
DECLARE c_ALTSCHEMA CURSOR FOR
SELECT 'ALTER SCHEMA dbo TRANSFER lansweeperuser.' + name + ';'
FROM sys.objects
WHERE SCHEMA_NAME(SCHEMA_ID) = 'lansweeperuser'
DECLARE @SQLStmt NVARCHAR(200)
OPEN c_ALTSCHEMA
FETCH NEXT FROM c_ALTSCHEMA INTO @SQLStmt
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC(@SQLStmt)
FETCH NEXT FROM c_ALTSCHEMA INTO @SQLStmt
END
CLOSE c_ALTSCHEMA
DEALLOCATE c_ALTSCHEMA
END
GO
/* Resets the lansweeperuser SQL user */
USE lansweeperdb
GO
IF EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'lansweeperuser')
DROP SCHEMA lansweeperuser
GO
IF EXISTS (SELECT 1 FROM sys.database_principals WHERE name = 'lansweeperuser')
DROP USER lansweeperuser
GO
USE MASTER
GO
IF EXISTS (SELECT 1 FROM sys.server_principals WHERE name = 'lansweeperuser')
DROP LOGIN lansweeperuser
GO
CREATE LOGIN lansweeperuser
WITH PASSWORD = 'lansweeperuserpassword',
CHECK_POLICY = OFF,
DEFAULT_DATABASE = lansweeperdb,
DEFAULT_LANGUAGE = [English]
GO
USE lansweeperdb
GO
CREATE USER lansweeperuser FOR LOGIN lansweeperuser
GO
EXEC sp_addrolemember [db_owner], 'lansweeperuser'
GO
Lansweeper dropped support for SQL Server 2014 and earlier after version 11.2.2.0, so plan an upgrade if you're still on it.