<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amirul Zharfan on Medium]]></title>
        <description><![CDATA[Stories by Amirul Zharfan on Medium]]></description>
        <link>https://medium.com/@amizz?source=rss-fe007fbb1bd9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2RQH8pds-Dh1gu4r8f0ioA.jpeg</url>
            <title>Stories by Amirul Zharfan on Medium</title>
            <link>https://medium.com/@amizz?source=rss-fe007fbb1bd9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:25:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amizz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Guide to Creating Roles and Databases in PostgreSQL 15]]></title>
            <link>https://medium.com/@amizz/a-guide-to-creating-roles-and-databases-in-postgresql-15-81f1f735f368?source=rss-fe007fbb1bd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/81f1f735f368</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Amirul Zharfan]]></dc:creator>
            <pubDate>Tue, 29 Aug 2023 15:15:08 GMT</pubDate>
            <atom:updated>2023-08-29T15:19:26.490Z</atom:updated>
            <content:encoded><![CDATA[<p>PostgreSQL, often referred to as Postgres, is a powerful and open-source relational database management system. It’s known for its reliability, scalability, and advanced features. In PostgreSQL 15, managing roles and databases has become even more straightforward. In this guide, we’ll walk you through the process of creating roles and databases using PostgreSQL 15.</p><h4>TLDR</h4><pre>CREATE DATABASE mydb;<br>CREATE USER myuser WITH ENCRYPTED PASSWORD &#39;SOME_PASSWORD&#39;;<br>GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;<br>ALTER DATABASE mydb OWNER TO myuser;</pre><h3>Creating a Database and Role</h3><p>To get started, you’ll need to have PostgreSQL 15 installed on your system. Once that’s set up, you can follow these steps to create a database and a role:</p><h4>Step 1: Accessing the PostgreSQL Shell</h4><p>Open your terminal and enter the PostgreSQL interactive terminal by typing:</p><pre>psql</pre><h4>Step 2: Creating a Database</h4><p>To create a new database, use the `CREATE DATABASE` command. Replace `mydb` with your desired database name:</p><pre>CREATE DATABASE mydb;</pre><h4>Step 3: Creating a Role</h4><p>Next, create a role using the `CREATE USER` command. This command also allows you to set an encrypted password for the user:</p><pre>CREATE USER myuser WITH ENCRYPTED PASSWORD ‘SOME_PASSWORD’;</pre><p>Replace `myuser` with the desired username and `’SOME_PASSWORD’` with the actual password you want to set.</p><h4>Step 4: Granting Privileges</h4><p>Now it’s time to grant privileges to the user on the newly created database. Use the `GRANT` command to give the user all privileges on the specified database:</p><pre>GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;</pre><h4>Step 5: Changing Database Ownership</h4><p>To ensure that the user has full control over the database, you can change the database’s ownership to the newly created user:</p><pre>ALTER DATABASE mydb OWNER TO myuser;</pre><h4>Step 6: Exiting the PostgreSQL Shell</h4><p>Finally, you can exit the PostgreSQL shell by typing:</p><pre>\q</pre><h3>Conclusion</h3><p>Managing roles and databases in PostgreSQL 15 is a fundamental skill for database administrators and developers. With just a few simple commands, you can create a new database, establish user roles, and grant privileges efficiently. This enhances the security and organization of your PostgreSQL environment, setting the stage for building powerful and reliable applications.</p><p>Remember to replace placeholder names like `mydb` and `myuser` with your actual database and role names. By following these steps, you’ll be well on your way to harnessing the capabilities of PostgreSQL 15 for your projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81f1f735f368" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>