ubuntu安装pgsql
1.更新系统的包管理器的本地软件包列表
sudo apt-get update
2.查看Ubuntu的版本
lsb_release -a
查询结果为:
可以自己去pgsql官网查看:
https://www.postgresql.org/download/linux/ubuntu/
3.找到符合自己版本的pgsql版本:
不符合红框里的:
apt install postgresql
符合红框里的:
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
4.启动pgsql
启动:
systemctl start postgresql
查看状态:
systemctl status postgresql
5.登录pgsql
登录:
sudo -u postgres psql
设置密码:
alter user postgres with password '123456';
退出:
exit;
密码登录:
psql -U postgres -d postgres -h 127.0.0.1 -p 5432
6.创建用户
创建用户:
CREATE USER admin WITH PASSWORD '123456' SUPERUSER;
退出:
exit;