> ## Documentation Index
> Fetch the complete documentation index at: https://docs.countrystatecity.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Database Installation

> Choose a versioned database export and follow the matching MySQL, PostgreSQL, SQLite, MongoDB, SQL Server or DuckDB recipe

Choose the export for your database engine. A Git clone contains reference files and source code; the complete downloadable datasets are release assets.

> [!NOTE]
>
> These instructions use [v5.2.0-export.1](https://github.com/dr5hn/countries-states-cities-database/releases/tag/v5.2.0-export.1), published 3 November 2026. Its core tables contain 250 countries, 5,327 states and 156,169 city records. API data and installed package snapshots can differ. Check the [latest release](https://github.com/dr5hn/countries-states-cities-database/releases/latest) before choosing another version.

## Available database formats

| Engine | Published asset | Import method |
| - | - | - |
| [MySQL](https://docs.countrystatecity.in/database/installation/mysql.md) | `sql-world.sql.gz` | Decompress, then run with `mysql` |
| [PostgreSQL](https://docs.countrystatecity.in/database/installation/postgresql.md) | `psql-world.sql.gz` | Decompress, then run with `psql` |
| [SQLite](https://docs.countrystatecity.in/database/installation/sqlite.md) | `sqlite-world.sqlite3.gz` | Decompress and open the database file |
| [SQL Server](https://docs.countrystatecity.in/database/installation/sql-server.md) | `sqlserver-world.sql.gz` | Decompress, then run with SSMS or `sqlcmd` |
| [MongoDB](https://docs.countrystatecity.in/database/installation/mongodb.md) | `mongodb-world-mongodb-dump.tar.gz` | Extract, then restore BSON with `mongorestore` |
| [DuckDB](https://docs.countrystatecity.in/database/installation/duckdb.md) | SQLite or Parquet source | Query through the SQLite extension or copy into DuckDB |

## Prerequisites

* Install a supported version of your chosen database and its client tools.
* Allow space for both the download and extracted data, plus engine indexes and temporary import files. Check actual asset sizes on the release page.
* Import into a new empty database or destination file. Back up application data before any replacement.
* Keep country, state and city files from the same release when joining separate extracts.

## What you will get

The pinned SQLite snapshot includes regions, subregions, countries, states, counties, county-to-state links, cities and postcodes. File layout and types vary by engine; inspect the [schema](https://docs.countrystatecity.in/database/schema.md) and the source files you install.

Country and state names are joined from parent tables. A city’s state link can be null, and county relationships can span more than one state. Use the relationship rules in the schema reference when building queries.

## Troubleshooting

* A missing `mysql/world.sql`, `pgsql/world.sql` or `sqlite/world.sql` path refers to an older distribution layout. Use the release asset listed above.
* A SQLite file is binary; SQL-script import commands do not apply to it.
* SQL Server tables use the `world` schema inside your chosen database.
* Do not compare exact API counts with a different installed snapshot.

## Next steps

[Inspect the schema](https://docs.countrystatecity.in/database/schema.md), [read the database overview](https://docs.countrystatecity.in/database/overview.md), or use the [hosted API](https://docs.countrystatecity.in/api/introduction.md) for managed access. Data use is subject to the [ODbL licence](https://opendatacommons.org/licenses/odbl/1-0/) and applicable source notices.


## Related topics

- [Country State City](https://docs.countrystatecity.in/index.md)
- [PostgreSQL Installation](https://docs.countrystatecity.in/database/installation/postgresql.md)
- [SQL Server Installation](https://docs.countrystatecity.in/database/installation/sql-server.md)
- [MySQL Installation](https://docs.countrystatecity.in/database/installation/mysql.md)
- [Database Schema](https://docs.countrystatecity.in/database/schema.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.