ubuntu下postgreSQL 配置
来源:互联网 发布:我国茶叶出口数据5014 编辑:程序博客网 时间:2024/05/17 07:37
一、安装并配置,并设置远程登陆的用户名和密码
1、安装postgreSQL
sudo apt-get update
sudo apt-get install postgresql-9.4
- 在Ubuntu下安装Postgresql后,会自动注册为服务,并随操作系统自动启动。
- 在Ubuntu下安装Postgresql后,会自动添加一个名为postgres的操作系统用户,密码是随机的。并且会自动生成一个名字为postgres的数据库,用户名也为postgres,密码也是随机的。
2、修改postgres数据库用户的密码为123456
打开客户端工具(psql)
sudo -u postgres psql
- 其中,sudo -u postgres 是使用postgres 用户登录的意思
- PostgreSQL数据默认会创建一个postgres的数据库用户作为数据库的管理员,密码是随机的
postgres=# ALTER USER postgres WITH PASSWORD '123456';
- postgres=#为PostgreSQL下的命令提示符,--注意最后的分号;
3、退出PostgreSQL psql客户端
postgres=# \q
4、修改ubuntu操作系统的postgres用户的密码(密码要与数据库用户postgres的密码相同)
切换到root用户
su root
删除PostgreSQL用户密码
sudo passwd -d postgres
- passwd -d 是清空指定用户密码的意思
设置PostgreSQL系统用户的密码
sudo -u postgres passwd
按照提示,输入两次新密码
- 输入新的 UNIX 密码
- 重新输入新的 UNIX 密码
- passwd:已成功更新密码
5、修改PostgresSQL数据库配置实现远程访问
vi /etc/postgresql/9.4/main/postgresql.conf
1.监听任何地址访问,修改连接权限
#listen_addresses = 'localhost' 改为 listen_addresses = '*'
2.启用密码验证
#password_encryption = on 改为 password_encryption = on
vi /etc/postgresql/9.4/main/pg_hba.conf
在文档末尾加上以下内容
host all all 0.0.0.0 0.0.0.0 md5
6、重启服务
/etc/init.d/postgresql restart
7、5432端口的防火墙设置
5432为postgreSQL默认的端口
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT
二、内部登录,管理数据库、新建数据库、用户和密码
1、登录postgre SQL数据库
psql -U postgres -h 127.0.0.1
2、创建新用户zhangps,但不给建数据库的权限
postgres=# create user "zhangps" with password '123456' nocreatedb;
- 用户名处是双引号
3、建立数据库,并指定所有者
postgres=#create database "testdb" with owner = "zhangps";
三、外部登录,管理数据库、新建数据库、用户和密码
1、在外部命令行的管理命令,创建用户pencil
sudo -u postgres createuser -D -P pencil
- 输入新的密码:
- 再次输入新的密码:
2、建立数据库(tempdb),并指定所有者为(pencil)
sudo -u postgres createdb -O pencil tempdb
- ubuntu下postgreSQL 配置
- ubuntu下postgreSQL安装配置
- ubuntu下postgreSQL安装配置
- ubuntu下postgreSQL安装配置
- Ubuntu下安装和配置PostgreSQL 8.1
- Ubuntu下Postgresql-8.4安装及配置
- Ubuntu 10.04下PostgreSQL 8.4 安装配置
- Ubuntu下Postgresql-8.4安装及配置
- Ubuntu下Postgresql-8.4安装及配置
- Ubuntu下Postgresql-8.4安装及配置
- Ubuntu下安装及配置Postgresql
- ubuntu安装配置postgreSQL
- ubuntu下安装postgresql
- ubuntu 下postgresql入门
- ubuntu下安装postgresql
- Ubuntu下安装配置postgresql 8.4及pgAdmin3
- Ubuntu下PostgreSQL数据库集群(PL/Proxy)配置方法
- Ubuntu下PostgreSQL数据库集群(PL/Proxy)配置方法
- 中国管理文化与需求分析中的陷阱之领导和员工话语权问题
- 转载张龙老师一篇关于IntelliJ IDEA的介绍
- express框架
- 用户管理材料
- PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
- ubuntu下postgreSQL 配置
- 开始写博客啦QAQ
- 微信小程序教程系列
- Leetcode——313. Super Ugly Number
- 搭建Ruby on Rails
- Qt creator 如何从.Ui文件中获取控件?类似findViewBy功能的实现
- 【H.264/AVC视频编解码技术详解】十三、熵编码算法(3):CAVLC原理
- Webcollector + Spring + MVC 搭建应用初探(四)
- linux的ssh登录