以下是一份CentOS下PostgreSQL的使用教程:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm。sudo dnf -qy module disable postgresql。sudo yum install -y postgresql16-server postgresql16(以16版本为例)。sudo /usr/pgsql-16/bin/postgresql-16-setup initdb。sudo systemctl start postgresql-16,sudo systemctl enable postgresql-16。/var/lib/pgsql/16/data/postgresql.conf,将listen_addresses设为'*'。/var/lib/pgsql/16/data/pg_hba.conf,添加host all all 0.0.0.0/0 md5以允许所有IP用MD5认证访问。sudo systemctl restart postgresql-16。sudo -i -u postgres。createdb your_database_name。CREATE USER your_username WITH PASSWORD 'your_password'。GRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_username。本地连接:psql -U postgres;远程连接:psql -U your_username -d your_database -h your_host -p your_port。