在ubuntu下安装postgresql
A,安装数据库
sudo apt-get install postgresql
查看安装的版本
psql --version
B,修改数据库里面postgres用户的密码
默认安装的postgresql数据库的用户名是postgres 密码随机的,需要设置一个密码。
neal@neal-Lenovo-Product:~$ sudo -u postgres psql
[sudo] password for neal:
psql (9.1.13)
Type "help" for help.
postgres=#
进入之后,修改postgres的登录密码为password
postgres=# alter USER postgres with PASSWORD 'changme'
退出
postgres=# \q
C,修改linux系统中postgres用户的密码
修改完后还要修改linux操作系统下用户postgres的密码(安装postgresql的时候,它会默认创建一个数据库的用户和 linux操作系统的用户,而且用户名都是postgres)
1.首先清空指定的用户名密码
neal@neal-Lenovo-Product:~$ sudo passwd -d postgres
2.设置postgres的用户密码,这个要和刚才设置的密码一致(为changme)
neal@neal-Lenovo-Product:~$ sudo -u postgres passwd
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
这样postgres的用户名和密码就修改成功了。
D,设置postgresql数据库能够远程访问
1.修改配置文件
neal@neal-Lenovo-Product:~$ sudo vi /etc/postgresql/9.1/main/postgresql.conf
59行修改监听地址
#listen_addresses = 'localhost' 为 listen_addresses = '*'
84行启动密码验证
#password_encryption = on 修改为 password_encryption = on
保存推出
2修改可以放问的ip段
neal@neal-Lenovo-Product:~$ sudo vi /etc/postgresql/9.1/main/pg_hba.conf
在文档末尾添加
#host replication postgres ::1/128 md5
host all all 0.0.0.0 0.0.0.0 md5
保存退出。
3,重启postgresql
neal@neal-Lenovo-Product:~$ sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.1 database server [ OK ]
可以试下
neal@neal-Lenovo-Product:~$ sudo psql -U postgres -h 192.168.1.104
参考出处
http://blog.sina.com.cn/s/blog_6af33caa0100ypck.html
A,安装数据库
sudo apt-get install postgresql
查看安装的版本
psql --version
B,修改数据库里面postgres用户的密码
默认安装的postgresql数据库的用户名是postgres 密码随机的,需要设置一个密码。
neal@neal-Lenovo-Product:~$ sudo -u postgres psql
[sudo] password for neal:
psql (9.1.13)
Type "help" for help.
postgres=#
进入之后,修改postgres的登录密码为password
postgres=# alter USER postgres with PASSWORD 'changme'
退出
postgres=# \q
C,修改linux系统中postgres用户的密码
修改完后还要修改linux操作系统下用户postgres的密码(安装postgresql的时候,它会默认创建一个数据库的用户和 linux操作系统的用户,而且用户名都是postgres)
1.首先清空指定的用户名密码
neal@neal-Lenovo-Product:~$ sudo passwd -d postgres
2.设置postgres的用户密码,这个要和刚才设置的密码一致(为changme)
neal@neal-Lenovo-Product:~$ sudo -u postgres passwd
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
这样postgres的用户名和密码就修改成功了。
D,设置postgresql数据库能够远程访问
1.修改配置文件
neal@neal-Lenovo-Product:~$ sudo vi /etc/postgresql/9.1/main/postgresql.conf
59行修改监听地址
#listen_addresses = 'localhost' 为 listen_addresses = '*'
84行启动密码验证
#password_encryption = on 修改为 password_encryption = on
保存推出
2修改可以放问的ip段
neal@neal-Lenovo-Product:~$ sudo vi /etc/postgresql/9.1/main/pg_hba.conf
在文档末尾添加
#host replication postgres ::1/128 md5
host all all 0.0.0.0 0.0.0.0 md5
保存退出。
3,重启postgresql
neal@neal-Lenovo-Product:~$ sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.1 database server [ OK ]
可以试下
neal@neal-Lenovo-Product:~$ sudo psql -U postgres -h 192.168.1.104
参考出处
http://blog.sina.com.cn/s/blog_6af33caa0100ypck.html