Quick Start
Prerequisites
Section titled “Prerequisites”Before you begin, ensure you have:
- Linux or macOS system
- Docker (optional, for containerized deployment)
- Telnet or netcat for basic connection testing
Installation
Section titled “Installation”Option 1: Native Installation (Recommended)
Section titled “Option 1: Native Installation (Recommended)”# Install HaruDBcurl -sSL https://raw.githubusercontent.com/Hareesh108/haruDB/main/scripts/install-harudb.sh | bash
# Verify installationharudb --version
Option 2: Docker Installation
Section titled “Option 2: Docker Installation”# Pull the latest imagedocker pull hareesh108/harudb:latest
# Run the containerdocker run -p 54321:54321 hareesh108/harudb:latest
Start the Server
Section titled “Start the Server”Native Binary
Section titled “Native Binary”# Basic startup./harudb --data-dir ./data
# With TLS encryption./harudb --data-dir ./data --tls
# Custom port./harudb --data-dir ./data --port 54322
# Port conflict detection./harudb --data-dir ./data# If port is in use: ⚠️ Port 54321 is already in use by: <process># Please stop the other service or use a different port
Docker
Section titled “Docker”# Run with volume mounting for persistencedocker run -p 54321:54321 -v $(pwd)/data:/app/data hareesh108/harudb:latest
# Run in backgrounddocker run -d -p 54321:54321 --name harudb hareesh108/harudb:latest
Connect to HaruDB
Section titled “Connect to HaruDB”Using Telnet (Basic)
Section titled “Using Telnet (Basic)”telnet localhost 54321
Using Netcat
Section titled “Using Netcat”nc localhost 54321
Using HaruDB CLI (Recommended)
Section titled “Using HaruDB CLI (Recommended)”haru-cli
You should see:
Welcome to HaruDB v0.0.5 🎉Type 'exit' to quit.
haruDB>
Your First Database Operations
Section titled “Your First Database Operations”1. Login to Database
Section titled “1. Login to Database”-- Login with default admin credentialsLOGIN admin admin123
-- Change the default password immediately!CHANGE PASSWORD admin123 MySecurePassword123!
2. Create a Table
Section titled “2. Create a Table”CREATE TABLE users (id, name, email, age);
3. Insert Data
Section titled “3. Insert Data”INSERT INTO users VALUES (1, 'Alice', 'alice@example.com', '25');INSERT INTO users VALUES (2, 'Bob', 'bob@example.com', '30');INSERT INTO users VALUES (3, 'Charlie', 'charlie@example.com', '35');
4. Query Data
Section titled “4. Query Data”-- Select all usersSELECT * FROM users;
-- Select specific columnsSELECT name, email FROM users;
-- Count recordsSELECT COUNT(*) FROM users;
5. Create an Index for Faster Queries
Section titled “5. Create an Index for Faster Queries”CREATE INDEX ON users (email);
6. Advanced Queries with WHERE Clauses
Section titled “6. Advanced Queries with WHERE Clauses”-- Equality filter (uses index)SELECT * FROM users WHERE email = 'alice@example.com';
-- Comparison operatorsSELECT * FROM users WHERE age > 30;
-- Pattern matchingSELECT * FROM users WHERE name LIKE 'A%';
-- Complex conditionsSELECT * FROM users WHERE age > 25 AND name LIKE 'A%';
6. Update Data
Section titled “6. Update Data”-- Update by row indexUPDATE users SET age = '26' ROW 0;
-- Update multiple columnsUPDATE users SET name = 'Alice Updated', email = 'alice.updated@example.com' ROW 0;
7. Delete Data
Section titled “7. Delete Data”-- Delete by row indexDELETE FROM users ROW 2;
8. Transactions
Section titled “8. Transactions”-- Begin a transactionBEGIN TRANSACTION;
-- Make multiple changesINSERT INTO users VALUES (4, 'David', 'david@example.com', '28');UPDATE users SET age = '27' ROW 0;
-- Commit the transactionCOMMIT;
-- Or rollback if neededBEGIN TRANSACTION;INSERT INTO users VALUES (5, 'Eve', 'eve@example.com', '32');ROLLBACK; -- This will undo the insert
9. Clean Up
Section titled “9. Clean Up”-- Drop the tableDROP TABLE users;
Complete Example Session
Section titled “Complete Example Session”Here’s a complete session demonstrating HaruDB’s capabilities:
-- Create tablesCREATE TABLE products (id, name, price, category);CREATE TABLE orders (id, product_id, quantity, total);
-- Insert sample dataINSERT INTO products VALUES (1, 'Laptop', '999.99', 'Electronics');INSERT INTO products VALUES (2, 'Mouse', '29.99', 'Electronics');INSERT INTO products VALUES (3, 'Desk', '199.99', 'Furniture');
-- Create indexesCREATE INDEX ON products (category);CREATE INDEX ON products (name);
-- Query with WHERE clausesSELECT * FROM products WHERE category = 'Electronics';SELECT * FROM products WHERE price > 100;
-- Complex querySELECT * FROM products WHERE category = 'Electronics' AND price < 50;
-- Transaction exampleBEGIN TRANSACTION;INSERT INTO orders VALUES (1, 1, 2, '1999.98');INSERT INTO orders VALUES (2, 2, 1, '29.99');COMMIT;
-- Verify transactionSELECT * FROM orders;
-- Clean upDROP TABLE products;DROP TABLE orders;
Next Steps
Section titled “Next Steps”Now that you’ve completed the quick start:
- Explore SQL Operations - Learn about advanced SQL features
- Understand Transactions - Dive into ACID compliance
- Optimize Performance - Learn about indexes and query optimization
- Secure Your Database - Set up authentication and user management
- Backup Your Data - Learn about backup and restore
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Port already in use:
# Kill existing processpkill harudb# Or use a different port./harudb --port 54322
Permission denied:
# Make binary executablechmod +x harudb
Connection refused:
# Check if server is runningps aux | grep harudb# Check port availabilitynetstat -tlnp | grep 54321
For more troubleshooting help, see the Troubleshooting Guide.