Setting up a database environment on Windows involves a series of steps and configurations to ensure smooth operations. In this guide, we'll walk through the setup process for XAMPP, PostgreSQL, and Adminer, along with troubleshooting tips for common errors.
XAMPP Installation
XAMPP serves as a robust toolkit for setting up a local server environment. Here are the steps:
Download and Install XAMPP: Visit Apache Friends and follow the installation instructions.
Download and Install PostgreSQL: Head to PostgreSQL's official site and download the specific version required for your project.
Download Adminer: Adminer, a management tool, can be obtained from Adminer's website.
Install Node Version: Depending on your project's requirements, install the Node version via NVM for Windows.
Configuration Steps
XAMPP Configuration
Update
php.ini
in Apache Config: Uncommentextension=pgsql
.Adjust
post_max_size
andupload_max_filesize
to400M
.Restart Apache to apply changes.
PostgreSQL Setup
- Install and Set Password: Install the specific version of PostgreSQL and set a password during installation.
Adminer Integration
Create Adminer Directory: Within
C:\xampp\htdocs
, create a new folder namedadminer
.Copy the downloaded Adminer file into
C:\xampp\htdocs\adminer
.Restart the Apache server.
Access Adminer via http://localhost/adminer/adminer.php with default credentials:
Username:
postgres
Password: Use the PostgreSQL password set during installation.
Additional Information
Working with PostgreSQL
Terminal Connection:
Connect through the terminal using
psql -U postgres
.Input password.
Database Operations:
List databases:
\l
.Connect to a database:
\c db_name
.List tables:
\dt
.Switch to a different database:
\c otherDB
.To drop a database with active connections:
SELECT * FROM pg_stat_activity WHERE pg_stat_activity.datname='mydb'; SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'mydb'; DROP DATABASE mydb;
Updates and Troubleshooting
Configuration Updates:
Update file paths and database details.
Adjust environment paths for
www
.
Common Errors:
node-gyp
Error: Resolve by installing VS Code Build Tools & Python vianpm install --g --production windows-build-tools
.Database Import Encoding Issue:
Check server and client encoding using
SHOW server_encoding;
andSHOW client_encoding;
.Set client encoding to
utf8
or direct to a specific file (\i [File Name].sql
).
Happy coding❤️!