![]() ![]() The final step is to connect to the database db. Postgres Docsįinally, we can disconnect from the database as user postgres with \q. There is no need to grant privileges to the owner of an object (usually the user that created it), as the owner has all privileges by default. Setting my_user as the database owner will grant this user all the necessary privileges. We can create a new database like so: postgres=# CREATE DATABASE db WITH OWNER='my_user' postgres=# ALTER USER my_user WITH SUPERUSER įor a list of other privilege options, see here. If necessary, we could give it SUPERUSER privileges. This will create a new user my_user with the password above. To avoid messing up, we’ll create a new user with fewer privileges: postgres=# CREATE USER my_user WITH PASSWORD '123456' It’s bad practice to manipulate databases using it. This shows that we’re connected to the database as user postgres. You are now connected to database "postgres" as user "postgres". Additionally, a complete list of psql commands can be obtained with \?. We can get the connection information using the command \c. Once connected, we’ll get the following prompt: postgres=# If none is given, it will default to the current active username as the database name. The above command is equivalent to: $ sudo -u postgres psql postgres With sudo -u postgres, we execute the psql tool as user postgres, which is the only postgres user just after installation. To connect to postgres as this user, we’ll use the psql command line tool. Postgres configurationīy default, postgres will add a database superuser postgres as well as a database with the same name. You can find other OS specific installation instructions on the official postgres website. We’ll use $ to indicate the command line (shell) prompt. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |