Debian安装PostgreSQL

PostgreSQL 官网:https://www.postgresql.org/

安装参考地址 https://www.postgresql.org/download/linux/debian/

安装:

# 创建文件存储库配置:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# 导入存储库签名密钥:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# 更新软件包列表:
sudo apt-get update

# 安装最新版本的 PostgreSQL.
# 如果您想要特定版本, 请在 'postgresql'后面加上'-版本号'。(例子:postgresql-14):
sudo apt-get install postgresql -y

debain 默认没有安装 sudo 命令,使用 apt-get install sudo 安装 sudo

这里安装当前最新版本-14

配置:

安装完成后,postgresql 默认只能本地访问需要修改配置,注意PostgreSQL版本号安装位置

编辑 nano /etc/postgresql/14/main/pg_hba.conf ,添加新的代码允许IPV4/IPV6外网访问

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             0.0.0.0/0               md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
host    all             all             0.0.0.0/0               md5

nano /etc/postgresql/14/main/postgresql.conf

# - Connection Settings -

listen_addresses = '*'		# what IP address(es) to listen on;
					# comma-separated list of addresses;
					# defaults to 'localhost'; use '*' for all
					# (change requires restart)

修改完成后重启 PostgreSQL

sudo systemctl restart postgresql

为postgresql增加密码,安装后默认是空密码,运行在公网上不安全

#进入postgres默认用户
sudo su - postgres

#进入数据库
psql

#修改密码
\password postgres

最后使用数据库连接工具测试连接,推荐工具:pgAdmin ,dbeaver

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇