搜索看看
ubuntu 20 apt安装PostgreSQL
1、apt安装PostgreSQL
root@vultr:/# apt install postgresql Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libllvm10 libpq5 postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common ssl-cert sysstat Suggested packages: postgresql-doc postgresql-doc-12 libjson-perl openssl-blacklist isag The following NEW packages will be installed: libllvm10 libpq5 postgresql postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common ssl-cert sysstat 0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Need to get 30.7 MB of archives. After this operation, 122 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 libllvm10 amd64 1:10.0.0-4ubuntu1 [15.3 MB] Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpq5 amd64 12.14-0ubuntu0.20.04.1 [116 kB] Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-client-common all 214ubuntu0.1 [28.2 kB] Get:4 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-client-12 amd64 12.14-0ubuntu0.20.04.1 [1,053 kB] Get:5 http://us.archive.ubuntu.com/ubuntu focal/main amd64 ssl-cert all 1.0.39 [17.0 kB] Get:6 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-common all 214ubuntu0.1 [169 kB] Get:7 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql-12 amd64 12.14-0ubuntu0.20.04.1 [13.5 MB] Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 postgresql all 12+214ubuntu0.1 [3,924 B] Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 sysstat amd64 12.2.0-2ubuntu0.2 [448 kB] ...... ......
2、切换用户,将postgres密码改为123456
root@vultr:/# su - postgres postgres@vultr:~$ psql psql (12.14 (Ubuntu 12.14-0ubuntu0.20.04.1)) Type "help" for help. postgres=# ALTER USER postgres PASSWORD '123456'; ALTER ROLE postgres=#
3、重启postgresql命令
sudo service postgresql restart
到此就安装完成了,默认用户名是postgres,默认密码是123456,默认端口是5432