Error while removing table in Postgresql

Asked

Viewed 258 times

0

I am trying to install and configure Postgresql on my machine, however I am having some doubts and some problems.

I followed the following steps of the installation tutorial on official website. I am using Linux Mint Cinnamon 18.2.

Here are the settings of my machine.


After installation, I followed this tutorial.

The first problem arose 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 reply, then tried the command sudo su - postgres, I entered my password and managed to change user.

I managed 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 strange the fact that even after executing the commands to provide the privileges to my newly created user, after executing the command \du my user privilege list 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?

  • GRANT ALL PRIVILEGES ON postgres. * TO michael@localhost IDENTIFIED BY '<password>'; syntax error at or near "TO"

  • It worked perfectly! Thank you very much!

1 answer

1


The command su in bash is used for lifting as super user (root) and keep the user as administrator after executing the command. Already the command sudo bash runs the command as administrator then returns to the current user. Only one of these two commands is required. Therefore the requested password was from the system root user.

About Permissions and Services :

Looks like you created the usership michael but did not link permissions to the database, run a GRANT All, should fix 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 examples of the syntax in this url as well:

Postgreesql Syntax Grant All

  • And why when I enter the command su and enter my password appears su: Authentication failure? Super user already comes with a default password?

  • The super user is the root of the machine, which user is connecting to the shell?

  • the user michael

  • I’d have to know what machine it’s on, is it a dedicated or shared server where they gave you access to the shell? In addition to this use Michael surely exists root a super user. Contact the server support and request the password access.

  • Everything is locally on my machine. I am root!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.