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
Related
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.
First I get this error "connect to address 10.0.0.102 and port 12489: Connection refused", then I made some changes according to forums and I changed nclient.ini file. I adjusted the allowed hosts and password.
Then server side the Status Information is changed. Now I get this error in Nagios Admin Panel:
NSClient - ERROR: Invalid password.
However, at Nagios XI Server I checked password and it's same as in nsclient.ini file on client side.
I used this command to check:
/usr/local/nagios/libexec/check_nt -H 'hostname' -s nagpasswd -p 12489 -v CPULOAD -w 80 -c 90 -l 5,80,90,10,80,9 NSClient
What might be the issue? Any help would be perfect.
after changing the password , you need to restart your nagios service once
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 want to set up the psql terminal tool in Centos 6.6
I have been given access to as database and i just want to use the terminal for writing queries to the database for information. I have no prior experience with psql before but I want to move on from the pgadmin3 gui.
I started off by installing psql:
yum install postgresql
but when I try to access it, ie. typing [root#localhost]# psql I get the following error:
psql: FATAL: database "root" does not exist
I've tried using:
psql --host=<DB instance endpoint> --port=<port> --username=<master user name> --password --dbname=<database name>
but that fails to work too, maybe this is really basic but im completely lost for setting this up
Use:
psql -U my_pgadmin_username postgres
or
psql -U my_pgadmin_username -h localhost postgres
Alternately, more typical usage:
sudo -u postgres psql
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.