PostgreSQL 10操作快速入门实验
文章目录
参考 PostgreSQL学习手册:https://www.postgresql.org/docs/10/
实验前提:先在电脑上用VirtualBox安装一台CentOS7虚拟机,然后在CentOS7上安装 PostgreSQL 10
一、安装VirtualBox(自行Google)
二、在VirtualBox上安装CentOS7(自行Google)
三、安装 PostgreSQL on CentOS7
sudo yum update -y
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm -y
yum install postgresql10-contrib postgresql10-server -y
rpm -qa | grep postgresql
输出结果:
postgresql10-server-10.11-2PGDG.rhel7.x86_64
postgresql10-libs-10.11-2PGDG.rhel7.x86_64
postgresql10-10.11-2PGDG.rhel7.x86_64
postgresql-libs-9.2.24-1.el7_5.x86_64
postgresql10-contrib-10.11-2PGDG.rhel7.x86_64
[root@vl-bg-anaylsis02 ~]# /usr/pgsql-10/bin/postgresql-10-setup initdb
输出结果:
Initializing database ... OK
# 启动postgresql
[root@vl-bg-anaylsis02 ~]# sudo systemctl start postgresql-10
# 设置开机自动启动
[root@vl-bg-anaylsis02 ~]# sudo systemctl enable postgresql-10.service
# postgres账号登录psql
su - postgres
psql
# 在psql中对postgresql进行操作
postgres=# ALTER USER postgres WITH PASSWORD 'post123'
postgres-# \du
postgres=# \l
postgres=# \q
# 切换到系统的root账号,对配置文件进行配置
su - root
vi /var/lib/pgsql/10/data/postgresql.conf
/var/lib/pgsql/10/data/postgresql.conf配置文件更改后的最终内容:
------------------------