The Countries States Cities database is available in multiple formats to support different technology stacks and use cases. Choose your preferred database platform and follow the corresponding installation guide.

Download Database Files

Get the latest database files from our GitHub releases page.

Available Database Formats

Quick Comparison

DatabaseFile SizeInstallation TimeBest Use Case
SQLite~50MB< 1 minuteDevelopment, mobile apps
MySQL~200MB2-5 minutesWeb applications
PostgreSQL~220MB3-6 minutesComplex applications
MongoDB~180MB2-4 minutesDocument-based apps
SQL Server~250MB5-10 minutesEnterprise environments
DuckDB~60MB1-2 minutesAnalytics workloads

Prerequisites

Before installing any database format:
1

Download Database Files

Download the appropriate database files from our GitHub repository.
git clone https://github.com/dr5hn/countries-states-cities-database.git
cd countries-states-cities-database
2

Verify Database Software

Ensure your target database system is installed and running.
Each installation guide includes specific version requirements and compatibility information.

What You’ll Get

After installation, your database will contain:
  • 250 Countries with ISO codes, regions, and metadata
  • 5,038 States/Provinces with administrative codes
  • 151,024 Cities with coordinates and timezone data
All data is regularly updated and includes comprehensive geographical information for worldwide coverage.

Need Help?


System Requirements

Minimum Hardware Requirements

Development Environment

  • • RAM: 2GB minimum, 4GB recommended
  • • Disk: 500MB free space
  • • CPU: Any modern processor

Production Environment

  • • RAM: 8GB minimum, 16GB+ recommended
  • • Disk: 2GB free space + growth capacity
  • • CPU: Multi-core processor recommended

Software Version Compatibility

  • MySQL: 5.7+ (8.0+ recommended)
  • PostgreSQL: 10+ (13+ recommended)
  • SQLite: 3.25+ (3.35+ recommended)
  • SQL Server: 2016+ (2019+ recommended)

Performance Optimization

-- Performance indexes for common queries
CREATE INDEX idx_cities_coordinates ON cities(latitude, longitude);
CREATE INDEX idx_countries_region ON countries(region);
CREATE INDEX idx_states_name ON states(name);
CREATE INDEX idx_cities_name ON cities(name);

Query Optimization Tips

  • Enable query cache if available
  • Configure appropriate connection pooling
  • Set up read replicas for high-traffic applications
  • Consider partitioning large tables by region/country

Backup Configuration

Always implement a backup strategy before using the database in production.
mysqldump -u root -p world > world_backup_$(date +%Y%m%d).sql

Troubleshooting

Common Issues

Problem: Special characters or emojis display incorrectlySolution: Ensure proper UTF-8 encoding
-- MySQL
ALTER DATABASE world CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- PostgreSQL  
CREATE DATABASE world WITH ENCODING 'UTF8';
Problem: Import process times out or failsSolution: Increase timeout limits and disable checks temporarily
-- MySQL
SET session sql_mode = '';
SET foreign_key_checks = 0;
SET autocommit = 0;
-- Run import --
COMMIT;
Problem: Out of memory errors during importSolution:
  • Increase database memory limits
  • Import tables individually
  • Use smaller batch sizes