{"id":640,"date":"2018-03-16T12:26:14","date_gmt":"2018-03-16T16:26:14","guid":{"rendered":"http:\/\/jasonralph.org\/?p=640"},"modified":"2019-12-20T14:10:34","modified_gmt":"2019-12-20T19:10:34","slug":"psql-connect-to-aws-redshift-from-windows-10-powershell","status":"publish","type":"post","link":"https:\/\/jasonralph.org\/?p=640","title":{"rendered":"PSQL Connect To AWS Redshift From Windows 10 PowerShell"},"content":{"rendered":"<p>Coming from a completely Linux background, I was tasked with connecting to a <code>aws redshift<\/code> cluster or a <code>postgres<\/code> cluster via Windows powershell and PSQL.  I knew it was possible and searching the internet came up with CMD prompt solutions, when I attempted via powershell, I was faced with the following error below, you will need to install postgres on windows10 to get access to the psql binary, you can get it here:<br \/>\n<a href=\"https:\/\/www.postgresql.org\/download\/windows\/\">https:\/\/www.postgresql.org\/download\/windows\/<\/a><\/p>\n<pre class=\"theme:solarized-dark lang:default decode:true \" >\r\nPS C:\\WINDOWS\\system32> psql.exe -h afs-rs-dev02.us-east-1.redshift.amazonaws.com  -p 5439 -U awsmaster benchmark01\r\nPassword for user awsmaster:\r\npsql: FATAL:  invalid value for parameter \"client_encoding\": \"WIN1252\"\r\n<\/pre>\n<p>Turns out a colleague of mine and I figured out you will need to set the variable PGCLIENTENCODING via the powershell command line.  This was expected but we could not nail down the syntax, we found it. <\/p>\n<pre class=\"theme:solarized-dark lang:default decode:true \" >\r\nPS C:\\WINDOWS\\system32> $env:PGCLIENTENCODING='utf-8';\r\nPS C:\\WINDOWS\\system32> psql.exe -h afs-rs-dev02.us-east-1.redshift.amazonaws.com  -p 5439 -U awsmaster benchmark01\r\nPassword for user awsmaster:\r\npsql (10.1, server 8.0.2)\r\nWARNING: Console code page (437) differs from Windows code page (1252)\r\n         8-bit characters might not work correctly. See psql reference\r\n         page \"Notes for Windows users\" for details.\r\nSSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)\r\nType \"help\" for help.\r\n\r\nbenchmark01=#\r\n<\/pre>\n<p>Once this is set, you can connect to PG as normal. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Coming from a completely Linux background, I was tasked with connecting to a aws redshift cluster or a postgres cluster via Windows powershell and PSQL. I knew it was possible and searching the internet came up with CMD prompt solutions, when I attempted via powershell, I was faced with the following error below, you will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[62,51,49,63,50],"class_list":["post-640","post","type-post","status-publish","format-standard","hentry","category-general-code","tag-aws","tag-postgres","tag-powershell","tag-psql","tag-redshift"],"_links":{"self":[{"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/posts\/640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jasonralph.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=640"}],"version-history":[{"count":5,"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/posts\/640\/revisions"}],"predecessor-version":[{"id":788,"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/posts\/640\/revisions\/788"}],"wp:attachment":[{"href":"https:\/\/jasonralph.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jasonralph.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jasonralph.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}