DEV Community

Gias Uddin
Gias Uddin

Posted on • Updated on

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!

Top comments (0)