惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
G
Google Developers Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
V
Vulnerabilities – Threatpost
Hugging Face - Blog
Hugging Face - Blog
I
Intezer
S
Securelist
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
Y
Y Combinator Blog
N
News | PayPal Newsroom
S
Schneier on Security
O
OpenAI News
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
Simon Willison's Weblog
Simon Willison's Weblog
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
N
News and Events Feed by Topic
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
The Cloudflare Blog
Last Week in AI
Last Week in AI
博客园 - 司徒正美
L
LangChain Blog
C
CERT Recently Published Vulnerability Notes
L
LINUX DO - 热门话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Hacker News
The Hacker News
博客园 - Franky
Attack and Defense Labs
Attack and Defense Labs
Security Latest
Security Latest
T
Tailwind CSS Blog
博客园_首页
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Security Blog
Microsoft Security Blog
V2EX - 技术
V2EX - 技术
腾讯CDC
V
V2EX

博客园 - 一路前行

RestTemplate之GET和POST调用和异步回调 ConditionalOnProperty fastjson序列化乱序问题 IE中的console.log spring boot 中添加mongodb支持 javacript onclick事件中传递对象参数 Java Lambda 表达式 对 Map 对象排序 比较两个list对象是否相同 ubuntu redis 自启动配置文件(关机有密码) spring中订阅redis键值过期消息通知 网站架构之性能优化(转) Json转Java Bean spring mvc 4 校验 java @ResponseBody返回值中去掉NULL字段 合并两个java bean对象非空属性(泛型) spring mvc 删除返回字符串中值为null的字段 十大Intellij IDEA快捷键(转) C#封装好的Win32API IntelliJ Idea 常用快捷键列表
ubuntu下postgreSQL安装配置
一路前行 · 2016-05-06 · via 博客园 - 一路前行

一、安装并配置,并设置远程登陆的用户名和密码

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

  • -O设定所有者为pencil

参考:http://blog.sina.com.cn/s/blog_6af33caa0100ypck.html