Error removing table in PostgreSQL

0

I'm trying to install and configure PostgreSQL on my machine, but I'm having some questions and some problems.

I followed the following steps of the installation tutorial on the official site . I'm using Linux Mint Cinnamon 18.2.

Here are the settings for my machine.

After installation, I followed this tutorial.

The first problem came up when typing the command su - postgres , because I was asked for a password, which was not the password of my current user and I have no idea what the password is. I looked for solutions on the internet and saw this response, then I tried the sudo su - postgres command, I entered my password and I was able to switch from user.

I was able to execute all the next commands except the last one ( DROP TABLE test.test; ), which resulted in the following error ERROR: must be owner of relation test

I also found it strange that even after running the commands to give the privileges to my newly created user, after running the command \du my user's list of privileges remained empty.

                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 michael   |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

What am I doing wrong?

    
asked by anonymous 14.12.2017 / 04:44

1 answer

1

The command su in bash is used to elevate as superuser ( root ) and keep the user as administrator after running the command. The sudo command in bash runs the command as administrator and then returns it to the current user. Only one of these two commands is required. Therefore the requested password was the root user of the system.

About Permissions and Users:

It looks like you created the michael user but did not link permissions to the database, run a GRANT All, should correct your problem:

Syntax in mysql:

  

GRANT ALL PRIVILEGES ON mydb. * TO michael @ localhost IDENTIFIED BY   'your_password';

Syntax in PostgreeSQL:

  

GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO   user_name;

See syntax examples in this url too:

PostgreeSQL Syntax Grant All

    
14.12.2017 / 09:20