{"id":131,"date":"2009-10-14T12:00:33","date_gmt":"2009-10-14T17:00:33","guid":{"rendered":"\/\/www.beauchamp.me\/techno\/?p=131"},"modified":"2012-06-06T14:55:39","modified_gmt":"2012-06-06T19:55:39","slug":"how-to-synchronize-users-after-a-database-restore","status":"publish","type":"post","link":"https:\/\/www.beauchamp.me\/techno\/blog\/2009\/10\/14\/how-to-synchronize-users-after-a-database-restore\/","title":{"rendered":"How to synchronize users after a database restore"},"content":{"rendered":"<p>After restoring a database on a different server than the one it is coming from, it will contain orphaned users. Here is how to find these orphaned users:<\/p>\n<blockquote>\n<pre class=\"brush:sql\">exec sp_change_users_login 'report'<\/pre>\n<\/blockquote>\n<p>In order to fix this, the logins for the reported users will have to be created on the new server if they do not exist.<\/p>\n<p>If the logins are the same as on the original server, it is easy to fix the orphaned users. Simply issue the following command for each orphaned user:<\/p>\n<blockquote>\n<pre class=\"brush:sql\">exec sp_change_users_login 'auto_fix', '&lt;replace this by the username...&gt;'<\/pre>\n<\/blockquote>\n<p><strong>UPDATE<\/strong>:<\/p>\n<p>For some reason I don&#8217;t understand, I got an error today when running this command:<\/p>\n<blockquote><p>\nAn invalid parameter or option was specified for procedure &#8216;sys.sp_change_users_login&#8217;\n<\/p><\/blockquote>\n<p>But I found a workaround. The command executed fine when I added the @Password parameter:<\/p>\n<blockquote>\n<pre class=\"brush:sql\">exec sp_change_users_login 'auto_fix', '&lt;replace this by the username...&gt;', @Password = '&lt;Replace this by the proper password&gt;'<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>After restoring a database on a different server than the one it is coming from, it will contain orphaned users. Here is how to find these orphaned users: exec sp_change_users_login &#8216;report&#8217; In order to fix this, the logins for the reported users will have to be created on the new server if they do not [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,12],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-sql-server-2005","category-sql-server-2008"],"_links":{"self":[{"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":5,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/posts\/131\/revisions\/202"}],"wp:attachment":[{"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}