I have an oracle database with password
+oS0pocWEpvaX++CN3]8nM‘2eX
If I try to connect with it using
sqlplus -S -L USER/'"+oS0pocWEpvaX++CN3]8nM‘2eX"'#host #script.sql
sqlplus -S -L USER/'+oS0pocWEpvaX++CN3]8nM‘2eX'#host #script.sql
sqlplus -S -L USER/"+oS0pocWEpvaX++CN3]8nM‘2eX"#host #script.sql
they all fail with error
ORA-01017: invalid username/password; logon denied
However the same password works in sql developer. How do I get sqlplus to work given that this password cannot be changed?
If you're using Linux, another idea to try would be to use a here-doc:
sqlplus << EOHD
CONNECT USER/+oS0pocWEpvaX++CN3]8nM‘2eX#host
#script
EXIT
EOHD
Login as SYS from the backend and reset the password of the user without any special characters.
Change it to a preferred password without special characters from your script.
Related
I have create a batch file and write code as per picture. But my problem is it is always asked my pgpassword though i have already define it first. I need a solution early. TIA.
set PGPASSWORD=123456
pg_dump -U postgres -W -F c YBD_ERP_Latest > E:\DBBackup\db_backup_%date:~-4%_%date:~3,2%_%date:~0,2%__%time:~0,2%_%time:~3,2%_%time:~6,2%.backup
The doc says:
-W
--password
Force psql to prompt for a password before connecting to a database [...].
So even though you have defined the password in PGPASSWORD, you have also forced psql to prompt for a password.
--> just remove the -W flag from pgdump options
I am trying to connect to a remote database using sqlcmd. I have tried something like this
sqlcmd -U <ComputerName>\Administrator -P adminpassword -S *.*.*.* -d mydatabase
But this is causing an error:
Failed to Login failed for user '\Administrator'
If I log onto the server where my database and run the command, it won't let me log in, either. But if I go into my SQL Server database and create a SQL Server user and run the same command with those details, I can log in.
But what I want to do is log in via the Administrator user from a different machine. Does anyone see what I'm doing wrong?
With Windows credentials you should use -E:
sqlcmd -E -S *.*.*.* -d mydatabase
I'm trying to connect to my SQL Server from a Linux terminal using SQSH. The line is:
sqsh -S <ip address> -U <DOMAIN\user>
which throws an error:
Msg 18456, Level 14, State 1 Server 'DC2', Line 1
Login failed for user ''.
Notice that it seems to have removed the '\' which separates my domain and user.
On the server side, my event log confirms the same thing. The event reads:
Login failed for user 'DOMAINuser'.
Reason: Could not find a login matching the name provided.
I've tried using single and double quotation marks to encapsulate the domain and user name, but when I do that, the request does not even make it to the server, probably because the quotes signify something else syntactically.
Does anyone know what I'm doing wrong?
sqsh uses the FreeTDS configuration file by default, so the version of TDS can be specified. A full description can be found here, but the command line result should look like this:
sqsh -S<config file name> -D <database name> -U <domain>\\<user> -P <password / hash>
Example:
sqsh -S mssql -D MyDB -U DOMAIN\\testuser -P MyTestingClearPassword1
I have create a new user in pgsql with no password. But when i try to create a database for this user it prompts for a password
>createuser -d -S -R -U postgres test1
Password:
>createdb -U test1 db1
Password:
i have tried the superuser password but it gives me the error :
createdb: could not connect to database template1: FATAL: password authentication failed for user "test1"
Please help,
Thank you
There is an alternative way to create user by prompting password.
You can give -P option while creating user.
Like:
createuser -d -S -R -U postgres test1
This may work for you,
psql -c "CREATE DATABASE mydb" "user=postgres dbname=postgres password=something_secret"
You need to run this from command-prompt. Go to the PostgreSQL folder where you can find the program psql and try this command. mydb would be the database name.
Reference: How to prevent asking for password when creating new database in PostgreSQL 10?
Thanks to: Jasen and Mladen Uzelac
I am trying to copy one table from one database to another:
sudo -u postgres pg_dump -t _stats db30 | psql db8;
However, I always get asked for a password, and I do not know what it is. Is there a way to do this without pg_dump? Is there a way so that I can not be asked for a password when I run psql?
Note, to get into postgres I have to run sudo -u postgres psql instead of psql
User management and permission on a postgres server is a complex topic, but you have probably only a server installed on your desktop and use it only on localhost, so security is not so important.
You have to do 3 steps:
1) Edit the pg_hba.conf file and restart the server
2) Login with psql and set a password for the user postgres
3) Edit (or create) the file ~/.pgpass
NOTE: you could use the authentication method trust in pg_hba.conf and avoid the step 2 and 3, but this is really TOO permissive, and you shouldn't use it, even on localhost.
The pg_hba.conf file
To understand the file pg_hba.conf please read here: http://www.postgresql.org/docs/9.4/static/auth-pg-hba-conf.html
Basically, if you server is on localhost and security does not matter, you can simply allow all user to connect with md5 authentication method.
If you don't know, where this file is, use this command:
locate pg_hba.conf
Probably is in /etc/postgresql/9.3/main/pg_hba.conf or similar.
Edit the file and change the already existing lines so (at end of the file):
local all all md5
host all all 127.0.0.1/32 md5
Now restart the server with
sudo service postgresql restart
Set a password for the user postgres
First login in psql:
sudo -u postgres psql
Now, within psql, change the password:
ALTER USER postgres PASSWORD 'your-password';
The pgpass file
Now you can login in psql with psql -U postgres (without sudo -u postgres) but have to enter the password. To avoid to digit the password every time, you can set up the pgpass file. If does not already exist, you must create a file named .pgpass in your home directory. The file must be owned by your user and be readable only by your user:
chown $USER:$USER ~/.pgpass
chmod 600 ~/.pgpass
Now write in the file those lines:
localhost:5432:*:postgres:your-password
127.0.0.1:5432:*:postgres:your-password
Alternately you can use the environment variable PGPASSWORD: http://www.postgresql.org/docs/9.4/static/libpq-envars.html
Ready. Now you can login in postgres with psql -U postgres without enter the password.