蒲公英联盟提供ghost win10,ghost win7,xp,装机纯净版,64位旗舰版,绿色软件,免费软件下载基地!

当前位置:主页 > 教程 > 服务器类 >

检查日志文件 /var/lib/pgsql/9.2/data/pg_log

来源:蒲公英系统┆发布时间:2018-07-12 12:00┆点击:

  3、初始化数据库并启动

  安装操作顺利完成后,对数据库进行初始化,然后启动服务

[root@wardking ~]# service postgresql-9.2 initdb Initializing database: [ OK ] [root@wardking ~]# service postgresql-9.2 start Starting postgresql-9.2 service: [ OK ]

  如果有错误信息出现,检查日志文件 /var/lib/pgsql/9.2/data/pg_log,查找线索

  4、 配置工作环境

  PostgreSQL数据库操作的默认账户为postgres,其操作目录为/var/lib/pgsql,配置文件.bash_profile中的默认内容为

[ -f /etc/profile ] && source /etc/profile PGDATA=http://www.3lian.com/var/lib/pgsql/9.1/data export PGDATA

  以上配置中包括了数据库所在的路径,但是没有可执行命令文件所在的目录,为操作便利,更正如下:

[ -f /etc/profile ] && source /etc/profile PGDATA=http://www.3lian.com/var/lib/pgsql/9.1/data export PGDATA PATH=$PATH:$HOME/bin:/usr/pgsql-9.1/bin export PATH

  5、设置默认账户postgres的操作密码

[root@wardking ~]# su – postgres -bash-4.1$ psql postgres postgres psql (9.2.1) Type “help” for help. postgres=# alter user postgres with password ‘postgres’; ALTER ROLE postgres=#

  6、 提升postgreSQL安全

  默认配置中,postgreSQL使用明文存储密码,非常不安全,需要修改配置文件,更改密码验证方式为md5

[root@wardking ~]# vi /var/lib/pgsql/9.1/data/pg_hba.conf # Put your actual configuration here # ———————————- # # If you want to allow non-local connections, you need to add more # “host” records. In that case you will also need to make PostgreSQL # listen on a non-local interface via the listen_addresses # configuration parameter, or via the -i or -h command line switches. # TYPE DATABASE USER ADDRESS METHOD # “local” is for Unix domain socket connections only local all all md5 # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. #local replication postgres peer #host replication postgres 127.0.0.1/32 ident #host replication postgres ::1/128 ident

  为了使配置文件生效,必须让postgreSQL重新载入配置,有多种方式可以实现:

  第一种方式: 直接使用命令操作

[root@wardking ~]# su – postgres -bash-4.1$ pg_ctl reload server signaled -bash-4.1$

  第二种方式:切换到postgres用户,通过psql命令,调用pg_reload_conf();

-bash-4.1$ psql postgres postgres psql (9.1.1) Type “help” for help. postgres=# select pg_reload_conf(); pg_reload_conf —————- t (1 row) postgres=#

  第三种方式:切换到postgres用户,同样使用psql命令,但无须登录PostgreSQL控制台

-bash-4.1$ psql postgres postgres -c “select pg_reload_conf();” Password for user postgres: pg_reload_conf —————- t (1 row) -bash-4.1$

  允许远程连接PostgreSQL数据库

  PostgreSQL的主配置文件postgresql.conf位于目录/var/lib/pgsql/9.2/data,其中CONNECTIONS AND AUTHENTICATION段中的配置如下

#—————————————————————————— # CONNECTIONS AND AUTHENTICATION #—————————————————————————— # – Connection Settings - #listen_addresses = ‘localhost’ # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to ‘localhost’, ‘*’ = all # (change requires restart) #port = 5432 # (change requires restart)
尚未注册畅言帐号,请到后台注册