<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog Patrick Espake &#187; inherit</title>
	<atom:link href="http://blog.patrickespake.com/tag/inherit/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.patrickespake.com</link>
	<description>O conhecimento evolui quando é compartilhado!</description>
	<lastBuildDate>Fri, 03 Sep 2010 04:24:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>Instalação do PostgreSQL</title>
		<link>http://blog.patrickespake.com/2009/11/09/instalacao-do-postgresql/</link>
		<comments>http://blog.patrickespake.com/2009/11/09/instalacao-do-postgresql/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:26:00 +0000</pubDate>
		<dc:creator>patrickespake</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[alter user]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cliente]]></category>
		<category><![CDATA[comando]]></category>
		<category><![CDATA[configurando]]></category>
		<category><![CDATA[createdb]]></category>
		<category><![CDATA[createrole]]></category>
		<category><![CDATA[deletar]]></category>
		<category><![CDATA[dropuser]]></category>
		<category><![CDATA[exemplo]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[inherit]]></category>
		<category><![CDATA[instalação]]></category>
		<category><![CDATA[listen_addresses]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[php_hba.conf]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql-8.3]]></category>
		<category><![CDATA[postgresql-client-8.3]]></category>
		<category><![CDATA[postgresql-common]]></category>
		<category><![CDATA[postgresql.conf]]></category>
		<category><![CDATA[psql]]></category>
		<category><![CDATA[senha]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[su]]></category>
		<category><![CDATA[superuser]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.patrickespake.com/?p=1060</guid>
		<description><![CDATA[Instalação Para instalar o PostgreSQL no Ubuntu digite o comando: sudo apt-get install postgresql-common postgresql-8.3 postgresql-client-8.3 Mudando a senha do usuário postgres sudo su postgres psql No console do psql ALTER USER postgres WITH PASSWORD 'postgres'; \q Configurando o postgresql.conf sudo vi /etc/postgresql/8.3/main/postgresql.conf Localizar a linha: listen_addresses = 'localhost' e mudar para: listen_addresses = '*' [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Instalação</strong></p>
<p>Para instalar o PostgreSQL no Ubuntu digite o comando:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> postgresql-common postgresql-<span style="color: #000000;">8.3</span> postgresql-client-<span style="color: #000000;">8.3</span></pre></div></div>

<p><strong>Mudando a senha do usuário postgres</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">su</span> postgres psql</pre></div></div>

<p>No console do psql</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> USER postgres <span style="color: #993333; font-weight: bold;">WITH</span> PASSWORD <span style="color: #ff0000;">'postgres'</span>;
\q</pre></div></div>

<p><strong>Configurando o postgresql.conf</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8.3</span><span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>postgresql.conf</pre></div></div>

<p>Localizar a linha:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">listen_addresses = <span style="color: #ff0000;">'localhost'</span></pre></div></div>

<p>e mudar para:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">listen_addresses = <span style="color: #ff0000;">'*'</span></pre></div></div>

<p>remova o carácter de comentário (#) da linha.</p>
<p>A opção listen_addresses permite definir qual host pode se conectar no servidor, exemplo: localhost somente para conexões locais, * para qualquer host ou um ip específico como: 192.168.1.236.</p>
<p><strong>Configurando pg_hba.conf</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8.3</span><span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>pg_hba.conf</pre></div></div>

<p>Adicionar no fim do arquivo a linha:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">host all all 192.168.1.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span> md5</pre></div></div>

<p>Essa configuração específica na ordem:</p>
<ul>
<li>host: Define regras para o protocolo TCP/IP, essa opção pode ser host, local ou hostssl;</li>
<li>all: Define qual banco de dados que essa regra se aplica, se definindo all será para todos;</li>
<li>all: Define qual usuário tem permissão para usar essa regra, se definido all será para todos;</li>
<li>192.168.1.0/24: Padrão CIDR, define qual faixa de ip&#8217;s podem ser conectar no servidor através do padrão CIDR;</li>
<li>md5: Método de autenticação, md5 padrão, trust para aceitar, reject para negar e mais algumas outras opções.</li>
</ul>
<p><strong>Reiniciar o PostgreSQL</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>postgresql-<span style="color: #000000;">8.3</span> restart</pre></div></div>

<p><strong>Usuários de banco de dados</strong></p>
<p>Criar um novo usuário. Para pode criar um novo usuário é necessário estar logado com o usuário postgres.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">su</span> postgres</pre></div></div>

<p>Existem duas formas de criar e deletar um usuário, uma através do shell e outra através do cliente postgre.</p>
<p><strong>Via Shell</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">createuser patrick</pre></div></div>

<p><strong>Via cliente postgres</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql
CREATE USER patrick;</pre></div></div>

<p>As duas opções criam patrick como superusuário.</p>
<p><strong>Exemplos:</strong></p>
<p>Definindo password</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> USER patrick PASSWORD <span style="color: #ff0000;">'123'</span>;</pre></div></div>

<p>Definindo privilégios de superusuário, permissão para criar databases e roles:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> USER patrick SUPERUSER INHERIT CREATEDB CREATEROLE;</pre></div></div>

<p>Mais informações: <a href="http://pgdocptbr.sourceforge.net/pg80/sql-createuser.html">http://pgdocptbr.sourceforge.net/pg80/sql-createuser.html</a>.</p>
<p><strong>Deletar usuário</strong></p>
<p>Via Shell:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dropuser patrick</pre></div></div>

<p>Via cliente postgres:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql
DROP USER patrick;</pre></div></div>

<p>Alterar usuário:</p>
<p>ALTER USER patrick PASSWORD &#8216;teste123&#8242;;</p>
<p>Mais detalhes:<a href=" http://pgdocptbr.sourceforge.net/pg80/sql-alteruser.html"> http://pgdocptbr.sourceforge.net/pg80/sql-alteruser.html</a>.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.patrickespake.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.patrickespake.com/2009/11/09/instalacao-do-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
