安装postgresql

1. 官网安装https://www.postgresql.org/download/linux/ubuntu/

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

sudo apt-get -y install postgresql-13

2. 安装完毕

zhangjie@zhangjie:~$ sudo -i -u postgres                ##超级用户 无密码

postgres@zhangjie:~$ psql                                        ##进入

psql (13.2 (Ubuntu 13.2-1.pgdg20.04+1))

Type "help" for help.

postgres=#

修改postgres 数据库用户密码(默认无)

postgres=# alter user postgres with password 'zhangjie1234'

3.退出 postgresql

postgres=# \q

4. 退出postgres用户 

postgres@zhangjie:~$ exit

4.其他

sudo /etc/init.d/postgresql start # 开启

sudo /etc/init.d/postgresql stop # 关闭

sudo /etc/init.d/postgresql restart # 重启

你可能感兴趣的:(安装postgresql)