不使用默认用户postgres安装PostgreSQL详细步骤
2015-09-08 20:26
627 查看
常见错误及解决方案:
报错:configure: error: readline library not found
解决方法:yum -y install readline-devel
报错:configure: error: no acceptable C compiler found in $PATH
解决方法:yum -y install
gcc
报错:configure: error: zlib library not found
解决方法:yum
install zlib-devel
报错:make: command not found
解决方法:yum
-y install automake autoconf libtool make
注意事项:data文件夹不能放在postgres 用户权限之外的目录下。
安装步骤如下
./configure --prefix=/usr/local/IMX_pgsql
make
make install
mkdir /usr/local/IMX_pgsql/data
chown imx:imx -R /usr/local/IMX_pgsql/
vi /usr/local/IMX_pgsql/data/postgresql.conf
su - imx
initdb -D /usr/local/IMX_pgsql/data/
su root
chown imx:imx -R /usr/local/IMX_pgsql
vi /etc/sysconfig/iptables
cd
/etc/rc.d/init.d
cp
/postgresql-9.0.4/contrib/start-scripts/linux IMX_pgsql
chmod +x IMX_pgsql
service IMX_pgsql start
su - imx
pg_ctl -D /usr/local/IMX_pgsql/data -l /usr/local/IMX_pgsql/data/serverlog start
createuser -W imx_sql
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
createdb imx -O imx_sql
psql
alter database imx owner to imx_sql;
这种方式安装的PostgreSQL可以随意移植到别的服务器上,继续使用
移植
Postgresql 到98 服务器上过程
1.
创建用户:useradd imx
2.
解压pgsql.tar.gz:
tar zxvf pgsql.tar.gz
3.
注册环境变量在home/postgres/.bash_profile 末尾追加
export PATH=$PATH:/usr/local/pgsql/bin
export MANPATH=$MANPATH:/usr/local/pgsql/man
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib
3.
复制linux到/etc/init.d,注册服务:cp /usr/local/pgsql/linux /etc/init.d/postgresql
chkconfig
--add postgresql
4. su postgresql
5. 初始化数据库 initdb -D /usr/local/pgsql/data
6 切换到root 用户启动服务: service postgresql
start
postgresql默认情况下,远程访问不能成功,如果需要允许远程访问,需要修改两个配置文件,说明如下:
1.postgresql.conf
将该文件中的listen_addresses项值设定为“*”,在9.0 Windows版中,该项配置已经是“*”无需修改。
2.pg_hba.conf
在该配置文件的host all all 127.0.0.1/32 md5行下添加以下配置,或者直接将这一行修改为以下配置
host all all 0.0.0.0/0 md5
如果不希望允许所有IP远程访问,则可以将上述配置项中的0.0.0.0设定为特定的IP值。
报错:configure: error: readline library not found
解决方法:yum -y install readline-devel
报错:configure: error: no acceptable C compiler found in $PATH
解决方法:yum -y install
gcc
报错:configure: error: zlib library not found
解决方法:yum
install zlib-devel
报错:make: command not found
解决方法:yum
-y install automake autoconf libtool make
注意事项:data文件夹不能放在postgres 用户权限之外的目录下。
安装步骤如下
./configure --prefix=/usr/local/IMX_pgsql
make
make install
mkdir /usr/local/IMX_pgsql/data
chown imx:imx -R /usr/local/IMX_pgsql/
vi /usr/local/IMX_pgsql/data/postgresql.conf
su - imx
initdb -D /usr/local/IMX_pgsql/data/
su root
chown imx:imx -R /usr/local/IMX_pgsql
vi /etc/sysconfig/iptables
cd
/etc/rc.d/init.d
cp
/postgresql-9.0.4/contrib/start-scripts/linux IMX_pgsql
chmod +x IMX_pgsql
service IMX_pgsql start
su - imx
pg_ctl -D /usr/local/IMX_pgsql/data -l /usr/local/IMX_pgsql/data/serverlog start
createuser -W imx_sql
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
createdb imx -O imx_sql
psql
alter database imx owner to imx_sql;
这种方式安装的PostgreSQL可以随意移植到别的服务器上,继续使用
移植
Postgresql 到98 服务器上过程
1.
创建用户:useradd imx
2.
解压pgsql.tar.gz:
tar zxvf pgsql.tar.gz
3.
注册环境变量在home/postgres/.bash_profile 末尾追加
export PATH=$PATH:/usr/local/pgsql/bin
export MANPATH=$MANPATH:/usr/local/pgsql/man
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib
3.
复制linux到/etc/init.d,注册服务:cp /usr/local/pgsql/linux /etc/init.d/postgresql
chkconfig
--add postgresql
4. su postgresql
5. 初始化数据库 initdb -D /usr/local/pgsql/data
6 切换到root 用户启动服务: service postgresql
start
Postgresql允许远程访问配置修改
postgresql默认情况下,远程访问不能成功,如果需要允许远程访问,需要修改两个配置文件,说明如下:1.postgresql.conf
将该文件中的listen_addresses项值设定为“*”,在9.0 Windows版中,该项配置已经是“*”无需修改。
2.pg_hba.conf
在该配置文件的host all all 127.0.0.1/32 md5行下添加以下配置,或者直接将这一行修改为以下配置
host all all 0.0.0.0/0 md5
如果不希望允许所有IP远程访问,则可以将上述配置项中的0.0.0.0设定为特定的IP值。
相关文章推荐
- Linux socket 初步
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- 基于 Linux 集群环境上 GPFS 的问题诊断
- 谁是桌面王者?Win PK Linux三大镇山之宝
- vivi下重新调整分区
- Linux VS Unix:Linux欲一统天下 Unix不死
- linux下设定环境变量
- Linux下修改MySQL编码的方法