#SQL
Review
- 2023-04-07 17:14
一、Introduction #
二、Installation #
2.1: Installing on Fedora37 #
sudo dnf update
sudo dnf install postgresql-server postgresql-contrib2.2: Configuration #
sudo systemctl enable postgresql
sudo postgresql-setup --initdb --unit postgresql
sudo systemctl start postgresql修改默认密码
sudo -u postgres psqlpostgres=# \password postgresCREATE DATABASE my_project OWNER postgres;2.3: 配置允许远程访问 #
The postgresql server is using two main configuration files
/var/lib/pgsql/data/postgresql.conf/var/lib/pgsql/data/pg_hba.conf
配置 pg_hba.conf
#
```sh
sudo vim /var/lib/pgsql/data/pg_hba.conf将下面的内容
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident替换为
# IPv4 local connections:
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 md5配置 postgresql.conf
#
sudo vim /var/lib/pgsql/data/postgresql.conf将下面内容
listen_addresses = 'localhost' # what IP address(es) to listen on;替换为
listen_addresses = '*' # what IP address(es) to listen on;配置防火墙 #
sudo firewall-cmd --permanent --add-port=5432/tcpsudo systemctl restart postgresql.service远程访问 #
通过客户端软件访问即可。