PostgreSQL 二进制安装步骤
2017-09-12 10:45
387 查看
本人测试系统为linux rh6.4,在linux版本中使用自定义的二进制安装方法。
下载安装版本:wget http://get.enterprisedb.com/postgresql/postgresql-9.4.9-1-linux-x64-binaries.tar.gz
useradd -g postgres postgres
tar xzf postgresql-9.4.9-1-linux-x64-binaries.tar.gz -C /opt
创建data目录:
mkdir -p /opt/pgsql/data
mkdir -p /opt/pgsql/log
授权:
chown -R postgres.postgres pgsql
#chown -R postgres.postgres postgresql
这里如果不授权,后面初始化时候会报权限错误:
fixing permissions on existing directory /data/service/postgresql/data … initdb: could not change permissions of directory “/data/service/postgresql/data”: Operation not permitted
OK 看到这个表示已经初始化成功了。
我们先使用默认配置启动postgresql,如需修改配置参数,可以在data的目录下的postgresql.conf修改。
登录数据库:
到此postgresql安装完成,可以开始正常服务,大家如果想创建自己的数据库,用户和密码可以使用:
验证使用:
添加新用户和创建数据库
验证登录
下载安装版本:wget http://get.enterprisedb.com/postgresql/postgresql-9.4.9-1-linux-x64-binaries.tar.gz
一、创建psotgres用户
groupadd postgresuseradd -g postgres postgres
二、创建必须目录
进入下载目录tar xzf postgresql-9.4.9-1-linux-x64-binaries.tar.gz -C /opt
创建data目录:
mkdir -p /opt/pgsql/data
mkdir -p /opt/pgsql/log
授权:
chown -R postgres.postgres pgsql
#chown -R postgres.postgres postgresql
这里如果不授权,后面初始化时候会报权限错误:
fixing permissions on existing directory /data/service/postgresql/data … initdb: could not change permissions of directory “/data/service/postgresql/data”: Operation not permitted
三、初始化
进入解压后的目录,切换用户到postgres[postgres@server2 /]# su postgres [postgres@server2 bin]$ ./initdb -E utf8 -D /opt/pgsql/data The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF-8". The default text search configuration will be set to "english". Data page checksums are disabled. creating directory /opt/pgsql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting dynamic shared memory implementation ... posix creating configuration files ... ok creating template1 database in /opt/pgsql/data/base/1 ... ok initializing pg_authid ... ok initializing dependencies ... ok creating system views ... ok loading system objects' descriptions ... ok creating collations ... ok creating conversions ... ok creating dictionaries ... ok setting privileges on built-in objects ... ok creating information schema ... ok loading PL/pgSQL server-side language ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to postgres ... ok syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using: ./postgres -D /opt/pgsql/data or ./pg_ctl -D /opt/pgsql/data -l logfile start
OK 看到这个表示已经初始化成功了。
我们先使用默认配置启动postgresql,如需修改配置参数,可以在data的目录下的postgresql.conf修改。
四、启动postgresql
启动注意必须使用postgres用户启动[postgres@server2 bin]$ pwd /opt/pgsql/bin [postgres@server2 bin]$ ./postgres -D /opt/pgsql/data/ > /opt/pgsql/log/postgres.log & [1] 36452 postgres@s0142-gz:/data/service/pgsql/bin$ LOG: database system was shut down at 2016-08-24 15:19:08 CST LOG: MultiXact member wraparound protections are now enabled LOG: database system is ready to accept connections LOG: autovacuum launcher started
登录数据库:
[postgres@server2 bin]$ ./psql psql.bin (9.4.9) Type "help" for help. postgres=#
到此postgresql安装完成,可以开始正常服务,大家如果想创建自己的数据库,用户和密码可以使用:
验证使用:
添加新用户和创建数据库
postgres=# create user srz with password '123'; CREATE ROLE postgres=# create database mydb with encoding='utf8' owner=srz; CREATE DATABASE
验证登录
[postgres@server2 bin]$ ./psql -U srz -d mydb psql.bin (9.4.9) Type "help" for help. mydb=>
相关文章推荐
- PostgreSQL 二进制安装步骤
- 通过源码编译安装PostgreSQL步骤及问题总结
- postgresql 9.4 在linux(Centos)环境的安装步骤详解
- PostgreSQL 8.2在Windows 2003 FAT32的安装步骤
- PostgreSQL在win7上安装详细步骤
- PostgreSQL安装详细步骤(windows)
- PostgreSQL 8.x在Windows 下的安装步骤
- PostgreSQL安装详细步骤(windows)
- 利用postgresql8.1.1源代码在hp-ux 11.11B上安装的步骤
- PostgreSQL在win7上安装详细步骤
- PostgreSQL在win7上安装详细步骤
- 二进制 mysql 的安装步骤
- MariaDB 二进制安装步骤
- PostgreSQL安装详细步骤(windows)
- PostgreSQL安装详细步骤(windows)
- 不使用默认用户postgres安装PostgreSQL详细步骤
- postgreSQL二进制快速安装
- PostgreSQL 安装步骤
- windows PostgreSQL 9.1 安装详细步骤
- PostgreSQL 二进制安装