|
| 1 | +# Deploy a Database |
| 2 | + |
| 3 | +This guide walks you through deploying and connecting to a PostgreSQL database. You'll learn how to create a database instance and connect to it using either the command line or a graphical interface. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | +- [Create a Database](#1-create-a-database) |
| 7 | +- [Configure Database Settings](#2-configure-database-settings) |
| 8 | +- [Wait for Deployment](#3-wait-for-deployment) |
| 9 | +- [Connect to Your Database](#4-connect-to-your-database) |
| 10 | + - [Using Command Line (CLI)](#using-command-line-cli) |
| 11 | + - [Using pgAdmin (GUI)](#using-pgadmin-gui) |
| 12 | + |
| 13 | +(1-create-a-database)= |
| 14 | +## 1. Create a Database |
| 15 | +Navigate to the "Database" section and click the "New" button to start the creation process. |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +(2-configure-database-settings)= |
| 20 | +## 2. Configure Database Settings |
| 21 | +Configure your database by providing the following information: |
| 22 | +- Database name |
| 23 | +- Username |
| 24 | +- Password |
| 25 | +- Hardware specifications (optional) |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +> ⚠️ **Important Security Note** |
| 30 | +> Create a strong password that includes: |
| 31 | +> - Uppercase and lowercase letters |
| 32 | +> - Numbers |
| 33 | +> - Special characters |
| 34 | +> |
| 35 | +> Store this password in a secure location - you'll need it to connect to your database. |
| 36 | +
|
| 37 | +(3-wait-for-deployment)= |
| 38 | +## 3. Wait for Deployment |
| 39 | +The deployment process typically takes about 1 minute. You'll see a progress indicator, and once complete, your database status will change to "Running". |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +(4-connect-to-your-database)= |
| 44 | +## 4. Connect to Your Database |
| 45 | +Choose one of the following methods to connect to your database: |
| 46 | + |
| 47 | +(using-command-line-cli)= |
| 48 | +### Using Command Line (CLI) |
| 49 | + |
| 50 | +1. **Install the PostgreSQL client** |
| 51 | + ```sh |
| 52 | + # Ubuntu/Debian |
| 53 | + sudo apt-get install postgresql-client |
| 54 | + |
| 55 | + # macOS |
| 56 | + brew install libpq |
| 57 | + brew link --force libpq |
| 58 | + |
| 59 | + # Windows |
| 60 | + # Download from https://www.postgresql.org/download/windows/ |
| 61 | + ``` |
| 62 | + |
| 63 | +2. **Connect using PSQL** |
| 64 | + Copy the connection command from the UI and paste it into your terminal: |
| 65 | + ```sh |
| 66 | + psql -h {DATABASE-URL} -U {USERNAME} {DATABASE_NAME} |
| 67 | + Password for user ...: {DATABASE_PASSWORD} |
| 68 | + ``` |
| 69 | +  |
| 70 | + |
| 71 | +3. **Test your connection** |
| 72 | + Try creating a sample table: |
| 73 | + ```sql |
| 74 | + -- Create a users table |
| 75 | + CREATE TABLE users ( |
| 76 | + id SERIAL PRIMARY KEY, |
| 77 | + username VARCHAR(100) UNIQUE NOT NULL, |
| 78 | + email VARCHAR(255) UNIQUE NOT NULL, |
| 79 | + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP |
| 80 | + ); |
| 81 | + |
| 82 | + -- Add a test user |
| 83 | + INSERT INTO users (username, email) |
| 84 | + VALUES ('testuser', 'test@example.com'); |
| 85 | + |
| 86 | + -- Verify the data |
| 87 | + SELECT * FROM users; |
| 88 | + ``` |
| 89 | + |
| 90 | +(using-pgadmin-gui)= |
| 91 | +### Using pgAdmin (GUI) |
| 92 | + |
| 93 | +1. Launch pgAdmin on your computer |
| 94 | +2. In the browser panel, right-click "Servers" → "Create" → "Server..." |
| 95 | +3. Configure your connection: |
| 96 | + | Tab | Field | Value | |
| 97 | + |-----|-------|-------| |
| 98 | + | General | Name | Your choice | |
| 99 | + | Connection | Host | Your database URL | |
| 100 | + | Connection | Port | 5432 | |
| 101 | + | Connection | Database | Your database name | |
| 102 | + | Connection | Username | Your database username | |
| 103 | + | Connection | Password | Your database password | |
| 104 | +4. Click "Save" to establish the connection |
| 105 | +5. Your database will appear in the server list |
| 106 | + |
0 commit comments