Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
PostgreSQL 16 Administration Cookbook

You're reading from  PostgreSQL 16 Administration Cookbook

Product type Book
Published in Dec 2023
Publisher Packt
ISBN-13 9781835460580
Pages 636 pages
Edition 1st Edition
Languages
Authors (5):
Gianni Ciolli Gianni Ciolli
Profile icon Gianni Ciolli
Boriss Mejías Boriss Mejías
Profile icon Boriss Mejías
Jimmy Angelakos Jimmy Angelakos
Profile icon Jimmy Angelakos
Vibhor Kumar Vibhor Kumar
Profile icon Vibhor Kumar
Simon Riggs Simon Riggs
Profile icon Simon Riggs
View More author details

Table of Contents (15) Chapters

Preface 1. First Steps 2. Exploring the Database 3. Server Configuration 4. Server Control 5. Tables and Data 6. Security 7. Database Administration 8. Monitoring and Diagnosis 9. Regular Maintenance 10. Performance and Concurrency 11. Backup and Recovery 12. Replication and Upgrades 13. Other Books You May Enjoy
14. Index

Creating a new user

In this recipe, we will show you two ways of creating a new database user—one with a dedicated command-line utility and another using SQL commands.

Getting ready

To create new users, you must either be a superuser or have the CREATEROLE privilege.

How to do it…

From the command line, you can run the createuser command:

pguser@hvost:~$ createuser bob

If you add the --interactive command-line option, you activate interactive mode, which means you will be asked some questions as follows:

pguser@hvost:~$ createuser --interactive alice
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n

Without --interactive, the preceding questions get no as the default answer; you can change that with the -s (--superuser), -d (--createdb), and -r (--createrole) command-line options.

In interactive mode, questions are...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}