A database you installed for one project is still running
SQL Server LocalDB, Postgres, MySQL and MongoDB keep data directories that persist long after the project. Where they are.
A local database installed for one project keeps running, keeps its data, and keeps its logs long after the project finished. Nothing about uninstalling the client or deleting the repository touches any of it.
Where each one keeps data
| Database | Windows location |
|---|---|
| SQL Server LocalDB | %USERPROFILE%\*.mdf and %LOCALAPPDATA%\Microsoft\Microsoft SQL Server Local DB |
| SQL Server | C:\Program Files\Microsoft SQL Server\MSSQL*\MSSQL\DATA |
| PostgreSQL | C:\Program Files\PostgreSQL\<version>\data |
| MySQL | C:\ProgramData\MySQL\MySQL Server <version>\Data |
| MongoDB | C:\Program Files\MongoDB\Server\<version>\data |
Get-Service | Where-Object { $_.Name -match 'SQL|postgres|mysql|mongo' } |
Select-Object Name, Status, StartTypeThat lists database services and whether they start with Windows. A service set to automatic on a machine where the project ended a year ago is using memory as well as disk.
The parts that grow on their own
- Transaction and write ahead logs. SQL Server's log file can exceed the database; Postgres keeps WAL segments.
- Binary logs. MySQL keeps these for replication and they are unnecessary on a development machine.
- Dropped tables. Space is not returned to the file system without a shrink, vacuum or optimise.
- Old major versions. Upgrading Postgres creates a new data directory and leaves the previous one.
Removing one safely
- Back up anything you might want. A dump file is small and turns a permanent decision into a reversible one.
- Stop the service in Services, and set it to Manual or Disabled.
- Uninstall through Settings, Apps, which removes the program.
- Then remove the data directory, which the uninstaller usually leaves deliberately.
LocalDB specifically
sqllocaldb info
sqllocaldb delete <instance>LocalDB instances are per user and easy to forget, and every Visual Studio project that used one created its own. The .mdf files frequently end up loose in the user profile, which is why they escape every cleanup.
Common questions
Where does SQL Server LocalDB store data on Windows?
Instance data lives under %LOCALAPPDATA%\Microsoft\Microsoft SQL Server Local DB, and project .mdf files frequently end up loose in the user profile, which is why they escape cleanups.
Is it safe to delete a database data directory?
Only after dumping anything you want to keep and stopping the service. The directory is the database, so removing it is permanent for that data.
Why does a local database keep growing?
Transaction and binary logs accumulate, and dropped tables do not return space to the file system without a shrink or vacuum. A service left running grows even when unused.
How do I find database services on Windows?
Run Get-Service and filter for SQL, postgres, mysql or mongo. A service set to start automatically for a project that ended is using memory as well as disk.