I'm trying to configure Solr to connect to a postgresql database. The problem is, the password contains special characters.
]T&FV{)pO-#lpMdD (this is an example of what am trying to use as password)
I tried escaping these characters with \ but it's not working.
I also tried with http encoding %5DT%26FV%7B%29pO-%40lpMdD but it's not working either.
Solr uses JDBC to connect to your database, so escaping the password would be the same as for regular JDBC strings.
You should be able to wrap your password in quotes - "<password>" - if you're going to use http encoding, it should be supplied at the end of the connection URL (i.e. /database?password=%5DT....
Related
Using a Postgresql URL connection string in the format of:
postgresql://user:secret#localhost
How do I handle special characters in that string (e.g., $) so that it will actually function when I connect to my postgres database?
I've tried simply URL encoding it, so for example, "test$" becomes "test%24" ... but that seems to be a problem as I get a "FATAL: password authentication failed " error when attempting to use it.
See Connection URIs in the doc.
There are a few things that don't seem quite right in your question:
URIs are supported by postgres since version 9.2 only, so with a 9.1 client that's not supposed to work at all. Or you're using a client that implements connection URIs itself.
Percent-sign encoding is supported. Per doc:
Percent-encoding may be used to include symbols with special meaning
in any of the URI parts.
Percent-encoding is not even necessary for a dollar character.
Tried with 9.3:
sql> alter user daniel password 'p$ass';
$ psql 'postgresql://daniel:p$ass#localhost/test'
works
$ psql 'postgresql://daniel:p%24ass#localhost'
works
psql 'postgresql://daniel:pass#localhost/test'
fails as expected: bad password.
Maybe your input shell has a different encoding and $ is not %24.
Check it out on https://www.urlencoder.org/
Hint:
If you use alter user "username" password 'p$ass''word' to set/change the password,
single quotes have to be masked with another singlequote.
Here is my connection string: mysql://admin:RandomString#sl-us-south-1-portal.serverNumber.dblayer.com:MyPORT/compose
Is the "RandomString" my password (obviously I changed it). Or what is that?
Or is there another IDE I can use to create the database? I am by no means dedicated to Workbench. I'm actually a SQL Server guy. Maybe a PostgreSQL instance has a web-IDE?
Yes, it is your password. A connection string is laid out in the RFC compliant format (specifically https://www.rfc-editor.org/rfc/rfc3986).
scheme://username:password#host:port/path
When trying to connect to my postgres server in Azure from psql client, I get the following error, even though I am using the correct username. How can I fix this?
psql: FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in <username#hostname> format.
As noted in the error text, you are required to follow the <username#hostname> format when trying to connect to postgresql server, whether you are doing it from psql client or using pgadmin. Using <username#hostname> format instead of just <username> should get rid of the error.
Read the quick-start documents for Azure portal and CLI to understand more about how to create and configure your postgres server.
The # sign in username works fine for objects but not connect strings. According to URI RFC-3986 username allows hex encoding. So replace the # with %40. user#host:pw#fullhost becomes user%40host:pw#fullhost
I have a connection string to a SQL Server 2012 DB:
$CONN_STR = "Server=SERVER;Database=mydb;User ID=myuser;Password=abc1$4def;"
I'm creating a connection in PowerShell, but the login fails due to invalid password. I know that the password is correct and validated that in SSMS. I've tested with another account and from what I can tell, the special character in the password is causing the failure.
How can I escape this in the connection string that I use in PowerShell?
try this:
$CONN_STR = 'Server=SERVER;Database=mydb;User ID=myuser;Password=abc1$4def;'
Use single quotes instead that way it wont think you are trying to reference a variable
I'm trying to run dokku on DigitalOcean to get a ruby/rails project up with postgres.
I got help to finding the logs, but I'm at loss when I see this :
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize': the scheme postgres does not accept registry part: root:aLZgAlQKbHbKhHHn#: (or bad hostname?) (URI::InvalidURIError)
any ideas on what I could perhaps look into?
the domain name is fritida.se the databasename i fritida (or was it fritida.se?)
I'm going to go and look for a way to list databases.
if your password contains unsafe characters
Connection string used for DATABASE_URL cannot contain special characters (anything other than [a-zA-Z0-9_~-\.], e.g. # is a common one to mess up). Solution is to url-encode.
see also https://stackoverflow.com/a/34280541/1733117