Tencentos 安装postgresql
时间: 2023-11-23 21:57:28 浏览: 33
以下是在TencentOS上安装PostgreSQL的步骤:
1. 使用以下命令安装PostgreSQL软件包:
```shell
sudo yum install postgresql-server
```
2. 初始化数据库:
```shell
sudo postgresql-setup initdb
```
3. 启动PostgreSQL服务:
```shell
sudo systemctl start postgresql
```
4. 设置PostgreSQL服务开机自启动:
```shell
sudo systemctl enable postgresql
```
5. 配置远程访问:
- 打开PostgreSQL配置文件:
```shell
sudo vim /var/lib/pgsql/data/postgresql.conf
```
- 找到并修改以下行:
```shell
#listen_addresses = 'localhost'
```
修改为:
```shell
listen_addresses = '*'
```
6. 配置访问权限:
- 打开PostgreSQL配置文件:
```shell
sudo vim /var/lib/pgsql/data/pg_hba.conf
```
- 在文件末尾添加以下行,允许所有IP地址访问:
```shell
host all all 0.0.0.0/0 md5
```
7. 重新启动PostgreSQL服务:
```shell
sudo systemctl restart postgresql
```
现在,您应该可以通过远程访问连接到您的TencentOS上的PostgreSQL服务器了。