#6 Introduction to PostgreSQL: Granting Database Privileges to A New User


English (Auto-generated)

in the last video we learned how to grant data base or mean we'll create database for specific user. However we don't always want to grant permissions or attributes to other users other than your main default account. So in this video we'll learn how to grant specific privileges to other users without letting them having to create database role in their role. So let's log into our main we'll check out the users. So as you can see test number one has a attribute called create DB but we don't always want to grant permission to other users. So let's revoke that, lets out her role. Test one with whenever you want to revoke the permission all you have to do is type the prefix note create tv So you don't really want to revoke back a super user. You would just type no super user but we don't have super user here. So we'll type no create dB Let's check it out. So test one is gone. So see why try to ps kgo post scratch. Remember when we want to log into a specific user about the type es que a postgres dash view for users they use your name will be logging like this and try to create a DVD will give us an error because we don't have the permission. So let's go back to our main were logged back into Alina making sure again we don't have any creative rules. So let's create a DB right now we can call it create yeah bees. Um as um ways again or maybe test database privilege is probably a better name. We take this to check them out. So test data. Uh where's my database? Great. Oh I have, I forgot the semicolon. See this is what happens when you forget the semi colon. It does not show up in your list of database. So let's create database again. Test database privilege. The semi colon I have a syntax error at create that is because in the last one we did not type the semi colon so the sentence did not finish. So what happens is the computer read it as create database. This database privilege and then create database again and then a semicolon. So it's actually like a long chain sentence. So that's why it's giving you this error. So all you do is typing it again and they will run and create the database. So check out list. So as you can see the test underscore database privilege Is granted to Elena however we wanted to grant to the owner. Test one. So we can actually type something. Cover it off privileges on database. Database privilege. Very long name to Test one I just can see has been granted um you will see that there is the empty space here. But yeah we can still connect to it. So we go back to ps kill postscript. You test one and then if we want to connect your database we have the type dash C. For connect on the database. So test database privilege you can see that I was able to connect as test one even though it didn't show here because I did granted the privilege. However, if I did not granted the privilege, see we exit and I go postgres issue cats because remember we have a user name called Cat and I try to connect to database has data. These privilege, we will see that it gives us a fatal error because kat was not granted the privilege. So once again we can exit the SQL Postgres am typing these over and over again because it's probably a news impacts to you and it will be hard to remember. So again, when you want along with a specific user P SQL postgres bash you and use your name. Well again we want to connect to database bash C. And Database me. So as database bullish, you're spelling it wrong and you can see that I was able to successfully connect to it.
169 Views 0 Likes 0 Comments

This video will teach you how to grant database privileges to another user.

Leave a comment (supports markdown format)