在Debian系统中配置PostgreSQL数据库的步骤如下:
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo -u postgres psql
psql
提示符下,创建一个新的超级用户(如果需要):CREATE ROLE postgres WITH PASSWORD 'your_password';
CREATE DATABASE your_database;
ALTER ROLE postgres SET client_encoding TO 'utf8';
ALTER ROLE postgres SET default_transaction_isolation TO 'read committed';
ALTER ROLE postgres SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE your_database TO postgres;
\q
/etc/postgresql/{version}/main/postgresql.conf
,找到以下参数并进行调整:listen_addresses
:设置为 '*'
以允许来自任何IP地址的连接。port
:设置为 5432
(PostgreSQL的默认端口)。max_connections
:根据需要设置最大连接数。保存配置文件并退出编辑器。
编辑 /etc/postgresql/{version}/main/pg_hba.conf
文件,以允许来自任何IP地址的连接。在文件末尾添加以下行:
host all all 0.0.0.0/0 md5
sudo systemctl restart postgresql
sudo ufw allow 5432/tcp
psql -U postgres -d your_database
输入密码后,您将连接到PostgreSQL数据库。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: Debian系统上怎么安装软件包