卸载安装
如果postgresql不是你想要的版本,先卸载再安装
[root@localhost ~]# yum remove postgresql*
yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7.8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql95-server.x86_64
yum install -y postgresql95-contrib.x86_64
启动数据库
[root@localhost bin]# /usr/pgsql-9.5/bin/postgresql95-setup initdb
Initializing database ... OK
[root@localhost bin]# systemctl enable postgresql-9.5
[root@localhost bin]# systemctl start postgresql-9.5
创建数据库
[root@localhost bin]# su - postgres
postgres=# create user sonar with password 'sonar';
CREATE ROLE
postgres=# create database sonardb owner sonar;
CREATE DATABASE
postgres=# grant all on database sonardb to sonar;
GRANT
[root@localhost bin]# su - sonar
[sonar@localhost ~]$ psql -U sonar -W sonardb
Pa