how to create user in oracle 19c database - rdbms

after installing oracle 19 C it was asking for username and password. what to type in that and how to create a new user with all permissions and authentication rights.(note i tried create user command by login as SYSDBA but it showing error as invalid common user or role name.
enter image description here
[enter image description here][2]

create user c##yourusername identified by tiger;

To create a user in a particular container do follows:
alter session set container
Crate user
Example:
alter session set "_ORACLE_SCRIPT"=true;
CREATE USER your_user_name IDENTIFIED BY your_password
After finished user creation please add grant permission to your user. Otherwise you may not be able to login in with this user.
GRANT Dba to your_user_name

alter session set "_ORACLE_SCRIPT"=true;
After execute the above script user has been created.

Related

How to reset password in postgresql (psql) for particular role in case when I list the role name it is not exist?

I have installed PostgreSQL for a long time but just currently learning it.
Here is what happened if I run psql in the command prompt
C:\Users\VandaRsq>psql
Password for user Vanda Rashq:
Since I forgot the password for the Vanda Rashq role but I remember for the postgres role, I run psql -U postgres.
I tried to list the role by using du command and the result is this:
I also tried using SELECT rolname FROM pg_roles command and yield:
I have tried to follow this tutorial and do ALTER USER "Vanda Rashq" WITH PASSWORD 'new_password'; but it returns ERROR: role "Vanda Rashq" does not exist
My question is, does the "Vanda Rashq" role actually still exist? If yes, how to reset (change) the password in case I forgot the password? If not, how to change the default role when running psql to postgres role
Notes: I have tried to uninstall the PostgreSQL and remove all of the directories but when I try to run psql, it still ask Password for user Vanda Rashq
If the user you're looking for is not listed after calling \du in psql then the user does not exist in the database.
Btw, you could also use a select to retrieve information about database users: select * from pg_catalog.pg_user;
EDIT:
Like #jjanes pointed out you get challenged for a password based on the USER configuration in yourpg_hba.conf (see docs).
For authentication method peer it is stated:
Obtain the client's operating system user name from the operating system and check if it matches the requested database user name.

How to give a user read only rights for 2 Tables in the same DB in PGAdmin 4.23

I want to give an access to my postgres DB for a user so he can have a read only data for 2 tables in my DB.
So, I have created a role for this:
CREATE ROLE stagiaire WITH
LOGIN
NOSUPERUSER
INHERIT
NOCREATEDB
NOCREATEROLE
NOREPLICATION
ENCRYPTED PASSWORD 'xxx';
Then, I also create a user in the up right menu "Users", user type is "User", and gave him a password.
user: email#gmail.com
pass: mypass
Now, user can login, but he sees nothing, and have access to nothing.
How can I link the user email#gmail.com with role "stagiaire"
I found the solution.
User must login. He sees nothing.
He must add himself the Server, so he must know URL to connect.
in my case, my internal URL: postgres.metadata.svc.cluster.local:5432
Then, he will use his login / password to connect.
Now, he will be able to see all resource, but will only be able to open the one with access granted.
Hope this helps

View database user and password in PgAdmin

How do I change a user's password in Postgresql (using PgAdmin) so that I can connect with Rails to the Postgres database using these credentials?
So far: In PgAdmin I right clicked the database name, clicked Create Script and then typed the command:
CREATE USER usr1 WITH PASSWORD 'pwd1!##$';
Question: where exactly in PgAdmin am I able to see the user and password or list of users and passwords? So far I am unable to see this in Db properties --> 'privileges'?? Any tips on other security elements? or something that can be improved in my current methods? Thanks a lot.
In the file "pgpass.conf" in this path:
C:\Users\[User's name]\AppData\Roaming\postgresql
Login roles are common for all databases in a server. You can see them in the bottom of the object browser (left panel).
To execute arbitrary SQL query open Query tool (Ctrl-E) from Tools in main menu or click on icon with 'SQL' (previously you have to select a database).
To change user password execute SQL:
ALTER ROLE username PASSWORD 'newpassword'
ALTER USER is an alias for ALTER ROLE. Read about it in documentation.
Run the query from pgadmin:
SELECT rolname, rolpassword FROM pg_authid;
This requires superuser privileges to protect the password.

PostgreSQL user's privileges listing for a particular database

i have a user created under login roles in pgAdmin. user's name is 'myApp'.
here is the pgsql syntax to create it.
CREATE ROLE myApp LOGIN
ENCRYPTED PASSWORD 'md58e0b379fc6e92422518682611bcf2d42'
NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
all these days i had my application developed by yii framework to connect to database with super user in my end. which is.. user 'postgres'
but after doing a release recently i started getting an error as below
i found its because of i have set permission to the myApp user role for newly created table but have missed to do the same for sequence so i wrote the below script to resolve..
GRANT ALL ON TABLE css_ataps_client_outgoing_call_dates_id_seq TO myAppAdmin;
GRANT SELECT, UPDATE ON TABLE css_ataps_client_outgoing_call_dates_id_seq TO myApp;
now i need to enable my application to connect to database using the same login as my production application which is myApp but not postgres.
but unfortunately it doesn't work unless i use postgres user. The error i got when trying to connect with myApp user is nothing. not even recorded in logs. so i can confirm that login details are same and its working and the issue could be the user myApp doesnt have read / write access to any single table. so i want to check for which table in database it doesnt have permission or vice versa.
please tell me a way to find this out. thanks.
This will do. Try and let me know.
GRANT ALL ON DATABASE <ur database name> TO myApp; <- not this
TRY THIS QUERY..!
GRANT SELECT,UPDATE,INSERT,DELETE ON ALL TABLES IN SCHEMA public TO myApp;

Oracle connection problem with Toad

I created a new user - CK - with Toad on 10g XE. An error popup when I use CK to login: ORA-01045: user CK lack create session privilege. What privilege do I should give to CK?
BTW: but I can use SqlPlus to login
You need to grant CREATE SESSION to the user you are trying to login as:
GRANT CREATE SESSION ON [object] TO [user];
The CREATE SESSION privilege is granted to users in order to create a session to the database. Without a session, you can't connect the database. If you're curious, you could read this Ask Tom: When not to use CREATE SESSION"...
Here's a good read on granting/revoking privileges.