{"id":3264,"date":"2020-04-29T21:48:22","date_gmt":"2020-04-29T22:18:22","guid":{"rendered":"https:\/\/ultering.com\/it4us\/?p=3264"},"modified":"2020-08-30T15:58:03","modified_gmt":"2020-08-30T16:28:03","slug":"postgresql-restoring-databases-with-different-user-from-the-current-windows-user","status":"publish","type":"post","link":"https:\/\/ultering.com\/it4us\/?p=3264","title":{"rendered":"POSTGRESQL: RESTORING DATABASES WITH DIFFERENT USER FROM THE CURRENT WINDOWS USER"},"content":{"rendered":"<h2><\/h2>\n<h2>Your current user on Windows doesn&#8217;t let you perform a PostgreSQL&#8217;s command?<\/h2>\n<p>Some PostgreSQL commands like createdb, pg_restore, etc. works assuming the current user logged on the console (or system).<\/p>\n<p>This approach makes simple things;<\/p>\n<p>Unfortunately, many times, the current user doesn&#8217;t exist on the database, mainly when restoring legacy databases.<br \/>\nOn *Nix environment, it is used sudo command to become a postgres user.<\/p>\n<p>On Windows, better than trying to do this running <em>runas<\/em> command is to create the Windows&#8217; current user on the database.<br \/>\nThen, you first create the user then run the cmd.<br \/>\nIt is an easier approach.<\/p>\n<p>Note: the user must be created with privileges to create tables.<\/p>\n<p>Follow the commands:<\/p>\n<p>&nbsp;<\/p>\n<div class=\"outputlisting2\">createuser -U postgres -W -e -l -r -s alsdias<br \/>\npsql -Upostgres -W<br \/>\n\\password alsdias<br \/>\npass:postgres<br \/>\npsql -Upostgres -d getit &lt; L:\\work\\dev\\devdb\\generic\\tests\\testone\\testone_pg\\dump\\pg_vmvd7b_getit_151213.dump<\/div>\n<p>&nbsp;<\/p>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Your current user on Windows doesn&#8217;t let you perform a PostgreSQL&#8217;s command? Some PostgreSQL commands like createdb, pg_restore, etc. works assuming the current user logged on the console (or system). This approach makes simple things; Unfortunately, many times, the current user doesn&#8217;t exist on the database, mainly when restoring legacy databases. On *Nix environment, it &#8230; <a href=\"https:\/\/ultering.com\/it4us\/?p=3264\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &#8220;POSTGRESQL: RESTORING DATABASES WITH DIFFERENT USER FROM THE CURRENT WINDOWS USER&#8221;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[17],"tags":[176,175,178,177],"class_list":["post-3264","post","type-post","status-publish","format-standard","hentry","category-database","tag-create-user","tag-postgresql","tag-restore-database","tag-windows"],"_links":{"self":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/3264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3264"}],"version-history":[{"count":3,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/3264\/revisions"}],"predecessor-version":[{"id":4156,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/3264\/revisions\/4156"}],"wp:attachment":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}