阅读量:0
Prerequisites
Before creating a database in pgAdmin on Debian, ensure:
- PostgreSQL server is installed and running (
sudo apt install postgresql postgresql-contrib && sudo systemctl start postgresql && sudo systemctl enable postgresql). - pgAdmin4 is installed (
sudo apt install pgadmin4). - A pgAdmin server connection is configured (follow steps in the “Configuring pgAdmin” section below).
Steps to Create a Database in pgAdmin
1. Configure pgAdmin Server Connection
To manage PostgreSQL databases via pgAdmin, you must first add a server connection:
- Open pgAdmin in your browser (e.g.,
http://localhost:5050) and log in. - In the left navigation pane, right-click the Servers node and select Create > Server.
- In the General tab, enter a descriptive name (e.g., “Local PostgreSQL”).
- Switch to the Connection tab and fill in:
- Host:
localhost(for local connections) or the server’s IP address. - Port:
5432(default PostgreSQL port; change if modified inpostgresql.conf). - Maintenance database:
postgres(default system database). - Username: The PostgreSQL superuser (e.g.,
postgres) or a custom user with permissions. - Password: The password for the selected user.
- Host:
- Click Save to establish the connection. The server will appear under the Servers node.
2. Create a Database
Once connected to the server, follow these steps to create a database:
- In the left navigation pane, expand the connected server node.
- Right-click the Databases node and select Create > Database.
- In the Create - Database dialog, configure the following:
- General tab:
- Database name: Enter a unique name (e.g.,
myapp_db). - Owner: Select a user (e.g.,
pgadmin_user; created in the “Prerequisites” section) who will own the database.
- Database name: Enter a unique name (e.g.,
- Optional Settings (adjust as needed):
- Character encoding: Use
UTF8(recommended for compatibility). - Collation/Locale: Keep default unless specific localization is required.
- Connection limits: Set maximum connections (e.g.,
-1for unlimited).
- Character encoding: Use
- General tab:
- Click Save to create the database. The new database will appear under the Databases node.
Key Notes
- If you encounter connection issues, verify:
- PostgreSQL service is running (
sudo systemctl status postgresql). postgresql.confallows connections (listen_addresses = '*') andpg_hba.confgrants access to your IP.- Firewall allows port 5432 (for local access,
ufw allow 5432/tcp).
- PostgreSQL service is running (
- For remote servers, replace
localhostwith the server’s IP and ensure PostgreSQL is configured to accept remote connections.
以上就是关于“如何在Debian PgAdmin中创建数据库”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm