Question

I want to create a new user in my database PostreSQL database hosted on Azure.

So, following the documentation from Microsoft for pgAdmin, I went to PGAdmin and ran the following command:

CREATE ROLE rikkiWITH LOGIN NOSUPERUSER INHERIT CREATEDB CREATEROLE NOREPLICATION PASSWORD 'Fete321@';

GRANT azure_pg_admin TO rikki;

FLUSH PRIVILEGES;

It worked well. Yet, when trying to create a new server with this new login I had some issues

enter image description here

  • I disabled SSL connection, so I don't have this error anymore
  • For the password error, I just copied and paste the password I just created but it gives back this error.

So can I create new users that would be able to connect remotely to my PostgreSQL database?

I tried to connect myself through command line and got

C:\Program Files\PostgreSQL\12\bin>psql --host=######.postgres.database.azure.com --port=5432 --username=rikki@######--dbname=capi
Password for user rikki@######:
psql: error: could not connect to server: FATAL:  password authentication failed for user "rikki"
FATAL:  password authentication failed for user "rikki"

No correct solution

OTHER TIPS

Read the title of the documentation link you have given. "Create users in Azure Database for MySQL server". You're using MySQL syntax to try and create a user in Postgres.

You'll be wanting to read this.

adding up on my comment:

you created a new user in server #1 - This user doesn't exist when creating a server #2 Why do you think you need another server - usually you want a new database-instance in server #1 for your new user

CREATE DATABASE <newdb>;

CREATE ROLE <db_user> WITH LOGIN NOSUPERUSER INHERIT CREATEDB NOCREATEROLE NOREPLICATION PASSWORD '<StrongPassword!>';

GRANT CONNECT ON DATABASE <newdb> TO <db_user>;

from Phil's linked manual page

if you want the new user with advanced privileges

Using an admin account, you may need to grant additional privileges to secure the objects in the database. Refer to the PostgreSQL documentation for further details on database roles and privileges. For example:

GRANT ALL PRIVILEGES ON DATABASE <newdb> TO <db_user>;
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top