<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pedromussato.com/index.php?action=history&amp;feed=atom&amp;title=Create_a_user_on_PostgreSQL</id>
	<title>Create a user on PostgreSQL - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pedromussato.com/index.php?action=history&amp;feed=atom&amp;title=Create_a_user_on_PostgreSQL"/>
	<link rel="alternate" type="text/html" href="https://wiki.pedromussato.com/index.php?title=Create_a_user_on_PostgreSQL&amp;action=history"/>
	<updated>2026-04-10T22:49:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.pedromussato.com/index.php?title=Create_a_user_on_PostgreSQL&amp;diff=242&amp;oldid=prev</id>
		<title>413vhcu1lq0463ob: Created page with &quot;To create an user on a PostgreSQL database you can use:  CREATE USER new_user WITH PASSWORD &#039;password&#039;; To guarantee full access on a database you can:  GRANT ALL PRIVILEGES ON DATABASE database_name TO new_user; Also to allow the user to connect on the database you need to:  GRANT CONNECT ON DATABASE database_name TO new_user; If you want the user to have full access to all tables, sequences, and other objects in the database, you can use:   \c database_name  -- To con...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.pedromussato.com/index.php?title=Create_a_user_on_PostgreSQL&amp;diff=242&amp;oldid=prev"/>
		<updated>2025-02-04T12:45:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;To create an user on a PostgreSQL database you can use:  CREATE USER new_user WITH PASSWORD &amp;#039;password&amp;#039;; To guarantee full access on a database you can:  GRANT ALL PRIVILEGES ON DATABASE database_name TO new_user; Also to allow the user to connect on the database you need to:  GRANT CONNECT ON DATABASE database_name TO new_user; If you want the user to have full access to all tables, sequences, and other objects in the database, you can use:   \c database_name  -- To con...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;To create an user on a PostgreSQL database you can use:&lt;br /&gt;
 CREATE USER new_user WITH PASSWORD &amp;#039;password&amp;#039;;&lt;br /&gt;
To guarantee full access on a database you can:&lt;br /&gt;
 GRANT ALL PRIVILEGES ON DATABASE database_name TO new_user;&lt;br /&gt;
Also to allow the user to connect on the database you need to:&lt;br /&gt;
 GRANT CONNECT ON DATABASE database_name TO new_user;&lt;br /&gt;
If you want the user to have full access to all tables, sequences, and other objects in the database, you can use:&lt;br /&gt;
&lt;br /&gt;
 \c database_name  -- To connect to the database&lt;br /&gt;
 GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO new_user;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO new_user;&lt;br /&gt;
&lt;br /&gt;
To ensure the user gets automatic privileges on any new tables or sequences created in the future, run the following:&lt;br /&gt;
 ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO new_user;&lt;br /&gt;
 ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO new_user;&lt;br /&gt;
&lt;br /&gt;
=== Full ===&lt;br /&gt;
 -- Connect to PostgreSQL&lt;br /&gt;
 psql -U postgres&lt;br /&gt;
 &lt;br /&gt;
 -- Create a new user&lt;br /&gt;
 CREATE USER new_user WITH PASSWORD &amp;#039;securepassword&amp;#039;;&lt;br /&gt;
 &lt;br /&gt;
 -- Grant full access to the database&lt;br /&gt;
 GRANT ALL PRIVILEGES ON DATABASE mydatabase TO new_user; &lt;br /&gt;
 &lt;br /&gt;
 -- Connect to the target database&lt;br /&gt;
 \c mydatabase &lt;br /&gt;
 &lt;br /&gt;
 -- Grant privileges on existing tables and sequences&lt;br /&gt;
 GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO new_user;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO new_user;&lt;br /&gt;
 &lt;br /&gt;
 -- Ensure future tables and sequences are also accessible&lt;br /&gt;
 ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO new_user;&lt;br /&gt;
 ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO new_user;&lt;/div&gt;</summary>
		<author><name>413vhcu1lq0463ob</name></author>
	</entry>
</feed>