A self-service web application for creating database accounts in a lab environment. Students can create their own MySQL or PostgreSQL databases with individual access credentials.
- Student Self-Service: Students can create their own database accounts
- Multi-Database Support: Supports MySQL and PostgreSQL
- Admin Panel: Administrators can manage all accounts and monitor system status
- Secure Authentication: Password hashing and session management
- Modern UI: Responsive design using Tailwind CSS
- Account Tracking: All accounts stored in SQLite database
Before running this application, ensure you have:
- Node.js (version 14 or higher)
- MySQL Server (if supporting MySQL databases)
- PostgreSQL Server (if supporting PostgreSQL databases)
-
Clone or download the project
cd c:\laragon-new\www\db-manager
-
Install dependencies
npm install
-
Configure environment variables
copy .env.example .env
Edit the
.env
file with your database server credentials:# Server Configuration PORT=3000 SESSION_SECRET=change-this-to-a-secure-secret # MySQL Configuration MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_ADMIN_USER=root MYSQL_ADMIN_PASSWORD=your_mysql_root_password # PostgreSQL Configuration POSTGRES_HOST=localhost POSTGRES_PORT=5432 POSTGRES_ADMIN_USER=postgres POSTGRES_ADMIN_PASSWORD=your_postgres_password
-
Start the application
# Development mode with auto-restart npm run dev # Production mode npm start
-
Access the application
- Main application: http://localhost:3000
- Admin panel: http://localhost:3000/admin/login
- Username: admin
- Password: admin123
- Install MySQL Server
- Create a root user or dedicated admin user
- Ensure the MySQL service is running
- Update the MySQL configuration in
.env
- Install PostgreSQL Server
- Create a superuser or dedicated admin user
- Ensure the PostgreSQL service is running
- Update the PostgreSQL configuration in
.env
- Visit the main page: http://localhost:3000
- Select database engine (MySQL or PostgreSQL)
- Enter desired username and password
- Click "Create Database Account"
- Use the provided credentials to connect to your database
- Visit admin login: http://localhost:3000/admin/login
- Login with admin credentials
- View all created accounts
- Monitor database connection status
- Delete accounts when needed
The application uses SQLite to track created accounts:
id
: Primary keyusername
: Database usernamedatabase_engine
: mysql or postgresqldatabase_name
: Generated database namecreated_at
: Account creation timestampstatus
: Account status (active/inactive)
id
: Primary keyusername
: Admin usernamepassword_hash
: Bcrypt hashed passwordcreated_at
: Admin creation timestamp
- Change Default Credentials: Update admin password in production
- Secure Database Servers: Ensure MySQL/PostgreSQL are properly configured
- Network Security: Use firewall rules to restrict database access
- SSL/TLS: Enable HTTPS in production environments
- Input Validation: All user inputs are validated and sanitized
db-manager/
├── app.js # Main application file
├── package.json # Dependencies and scripts
├── .env.example # Environment configuration template
├── config/
│ └── database.js # SQLite database configuration
├── routes/
│ ├── home.js # Home page routes
│ ├── admin.js # Admin authentication routes
│ └── api.js # API endpoints
├── utils/
│ └── databaseManager.js # MySQL/PostgreSQL management
├── views/
│ ├── index.ejs # Student home page
│ ├── admin-login.ejs # Admin login page
│ └── admin-dashboard.ejs # Admin dashboard
└── public/ # Static files (if needed)
GET /
- Student home pagePOST /api/create-account
- Create database account
GET /admin/login
- Admin login pagePOST /admin/login
- Admin authenticationGET /admin/dashboard
- Admin dashboardPOST /admin/logout
- Admin logoutGET /api/users
- Get all users (admin only)DELETE /api/users/:id
- Delete user (admin only)GET /api/test-connections
- Test database connections (admin only)
-
Database Connection Failed
- Check if MySQL/PostgreSQL services are running
- Verify credentials in
.env
file - Check firewall settings
-
Permission Denied
- Ensure admin user has CREATE USER and CREATE DATABASE privileges
- Check MySQL/PostgreSQL user permissions
-
Port Already in Use
- Change PORT in
.env
file - Kill existing processes using the port
- Change PORT in
The application provides detailed error messages for common issues:
- Invalid credentials
- Database connection failures
- Duplicate usernames
- Validation errors
This project is licensed under the ISC License.
For technical issues or questions, please contact your system administrator or instructor.