Linux安装PostGresql步骤
Linux安装PostGresql步骤
- 查看操作系统
cat /etc/redhat-release - 检查安装源
yum search postgresql - 安装
yum install postgresql-server - 初始化数据库
[root@localhost bin]# postgresql-setup initdb
数据库初始化成功:Initializing database ... OK - 查看数据库存储路径
cd /var/lib/pgsql/data - 启动数据库
service postgresql start
启动成功,会监听本机127.0.0.1的5432端口。
- 检查监听端口
netstat -nat - 查看启动状态
service postgresql status
添加开机自动启动 :
systemctl enable postgresql - 登录测试
默认情况下,我们使用psql postgres命令登录,使用的是root用户,会提示没有这个角色,我们按照提示使用psql -U postgres命令登录,发现提示Peer authentication failed for user “postgres”,我们只能切换到postgres用户,然后直接登录:
默认情况下,我们使用psql postgres命令登录,使用的是root用户,会提示没有这个角色,我们按照提示使用psql -U postgres命令登录,发现提示Peer authentication failed for user "postgres",我们只能切换到postgres用户,然后直接登录:
- 修改配置文件
- 重启数据库
service postgresql restart - 远程连接测试
Host all all 0.0.0.0/0 trust - 查看所有postgres进程
ps -ef|grep postgres