项目需要,使用国内数据库,临时学习了一下,做个记录,希望对大家有所帮助
相关文件
目录
1、基础设置
#postgresql 下载地址
#设置防火墙
#关闭防火墙
[root@postgres ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
#解压postgresql文件
[root@postgres ~]# tar -zxvf postgresql-9.2.24-1-linux-x64-binaries.tar.gz
[root@postgres ~]# mkdir /postgres
[root@postgres ~]# mv pgsql/ /postgres/
[root@postgres ~]# mkdir /postgres/pgsql_data
[root@postgres ~]# ll
总用量 4
drwxr-xr-x. 9 postgres root 103 2月 17 15:39 pgsql
drwx------. 14 postgres root 4096 2月 17 15:42 pgsql_data
2、创建用户
[root@postgres ~]# useradd postgres
[root@postgres ~]# passwd postgres # 两次输入密码并确认--自定义
#权限设置
[root@postgres ~]# chown -R postgres /monchickey/
#切换用户
[root@postgres ~]# su - postgres
3、安装
[postgres@localhost ~]$ /postgres/pgsql/bin/initdb -D /postgres/pgsql_data/
......
Success. You can now start the database server using:
/postgres/pgsql/bin/postgres -D /postgres/pgsql_data
or
/postgres/pgsql/bin/pg_ctl -D /postgres/pgsql_data -l logfile start
#出现如上内容即初始化成功
#修改配置文件
[postgres@localhost pgsql_data]$ vim postgresql.conf
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#listen_addresses属性改为*
#port默认是5432
两个属性都是注释的,需要打开
[postgres@localhost pgsql_data]$ vim pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.1.115/32 trust #指定IP连接
# IPv6 local connections:
host all all ::1/128 trust
#需要在IPv4中新增要连接psotgresql数据库的服务器IP地址
4、postgres安装esri库
st_geometry.so 在arcgis的安装目录下就有
[root@postgres ~]# ll
-rw-r--r--. 1 root root 10559787 2月 17 05:32 st_geometry.so
#将文件移动至 pgsql/lib/postgresql
[root@postgres ~}# mv st_geometry.so /postgres/pgsql/lib/postgresql
5、arcgis安装postgresql客户端
如下文件放置到arcgis安装目录的bin下面,例:ArcGIS\Desktop10.2\bin
6、基础命令
#开启
[root@postgres ~]# /postgres/pgsql/bin/pg_ctl -D /postgres/pgsql_data/ -l logfile start
#关闭
[root@postgres ~]# /postgres/pgsql/bin/pg_ctl -D /postgres/pgsql_data/ -l logfile stop
#刷新
[root@postgres ~]# /postgres/pgsql/bin/pg_ctl -D /postgres/pgsql_data/ -l logfile reload
#初始化
[root@postgres ~]# /postgres/pgsql/bin/initdb -D /postgres/pgsql_data/
#设置权限
[root@postgres ~]# chown -R postgres /postgres/
#创建用户--登录postgres用户后使用
#进入pgsql文件夹后执行命令
[postgres@localhost pgsql]# bin/psql
psql.bin (9.4.26)
Type "help" for help.
postgres=# \l #查看数据表命令 默认postgres,template0和1这3个库是不允许操作的
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =CTc/postgres +
| | | | | postgres=CTc/postgres+
| | | | | sde=CTc/postgres
template0 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres=# create user zb superuser password '123456';#创建用户命令
CREATE ROLE
postgres=# \q #退出交互式界面