# PostgreSQL Database Management
ServBay provides a built-in Adminer tool to facilitate the management of PostgreSQL databases. You can access this tool through the following link:
Here are detailed steps for managing PostgreSQL databases using Adminer:
# Obtain superuser Password for the Database
Open the ServBay interface.
Click on "Settings" in the left navigation bar.
- In the settings page, find the "Database Password" option.
- Copy the corresponding database superuser username and password.
# Using Adminer
Open your browser and go to Adminer (opens new window).
Input your PostgreSQL database superuser username and the password obtained from ServBay, then click login.
Within the Adminer interface, perform operations like:
Create a Database:
- Click "SQL Command" in the left sidebar.
- Input SQL commands to create a new database, for example:Then click "Execute."
CREATE DATABASE your_database_name;
1
Create Tables:
- Within the chosen database, click "Add Table."
- Input the new table's name and fields, then click "Save."
Import Data:
- In the chosen database, click "Import."
- Choose the SQL file to import and click "Import."
Other Operations: The left sidebar allows additional actions like modifying table structure, querying data, and deleting records.
Following these detailed steps, you can conveniently manage PostgreSQL databases using Adminer.
# Using Command-Line Management
For those who prefer command-line database management, install ServBay's command-line tools. Refer to the Command-Line Support documentation for detailed installation steps.
Once the command-line tools are installed, use the following command to connect to the PostgreSQL database:
# Connect to the local PostgreSQL database
psql -U <superuser> -d postgres
2
Replace <superuser>
with the superuser username obtained, for example, servbay_root
.
# Common PostgreSQL Operations
Here are some common PostgreSQL database operations:
List all databases:
\l
1Select a database:
\c database_name
1View all tables in a specified database:
\dt
1View the structure of a specified table:
\d table_name
1Create a user:
CREATE USER your_user WITH PASSWORD 'your_password';
1Grant user privileges:
ALTER USER your_user WITH SUPERUSER;
1Create a table:
CREATE TABLE your_table_name ( id SERIAL PRIMARY KEY, name VARCHAR(255) );
1
2
3
4Insert data:
INSERT INTO your_table_name (name) VALUES ('John Doe');
1Query data:
SELECT * FROM your_table_name;
1Update data:
UPDATE your_table_name SET name = 'Jane Doe' WHERE id = 1;
1Delete data:
DELETE FROM your_table_name WHERE id = 1;
1