DEV Community

Gias Uddin
Gias Uddin

Posted on • Edited on

1

How to create a superuser in PostgreSQL, using Linux

I will show you how to create a database by using a superuser. When we use any type of framework, we need to connect with the database by using a DB name. Table creation, query, and another task can be done by the framework.

Let’s assume you are using Linux Ubuntu and PostgreSQL already install in your pc.you can install PostgreSQL using this link.

Start the PostgreSQL server

sudo service postgresql start

Enter fullscreen mode Exit fullscreen mode

open terminal to enter into PostgreSQL database

sudo su -l postgres
Enter fullscreen mode Exit fullscreen mode

Now create user gias as a superuser, and assign a password immediately

postgres@gias ~ $
createuser -P -s -e gias
Enter password for new role: xyzzy
Enter it again: xyzzy
CREATE ROLE joe PASSWORD 'md5b5f5ba1a423792b526f799ae4eb3d59e' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;
Enter fullscreen mode Exit fullscreen mode

Create a database using this command createdb -O user dbname

createdb -O gias testdb
Enter fullscreen mode Exit fullscreen mode

enter into your database

psql -d testdb
show all table name
\dt
Enter fullscreen mode Exit fullscreen mode

Done, you can use your database name and username.

Thank you for reading my article! If you enjoyed it and would like to support my work, please consider buying me a coffee at Buy Me a Coffee. You can also learn more about me and my work by visiting my Giasuddin Bio and following me on LinkedIn and Twitter. Thank you for your support!

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay