{"id":393,"date":"2021-07-23T12:29:02","date_gmt":"2021-07-23T12:29:02","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/how-to-restore-a-users-database-access\/"},"modified":"2021-07-23T12:29:02","modified_gmt":"2021-07-23T12:29:02","slug":"how-to-restore-a-users-database-access","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/how-to-restore-a-users-database-access\/","title":{"rendered":"How to Restore a User&#8217;s Database Access"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>If a database user loses access to databases, you can restore the user\u2019s grants to the database with the <code>restoregrants<\/code> utility.<\/p>\n<h2 id=\"the-restoregrants-script\">The restoregrants script<\/h2>\n<p>To use the <code>restoregrants<\/code> script to restore the user\u2019s database access, run one of the following commands from the command line:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">usr<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">local<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">cpanel<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">bin<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">restoregrants<\/span> <span style=\"color:#f92672\">--<\/span><span style=\"color:#a6e22e\">cpuser<\/span>=<span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#a6e22e\">cpuser<\/span> <span style=\"color:#f92672\">--<\/span><span style=\"color:#a6e22e\">db<\/span>=<span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#f92672\">--<\/span><span style=\"color:#a6e22e\">dbuser<\/span>=<span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#a6e22e\">dbuser<\/span>\n<span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">usr<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">local<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">cpanel<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">bin<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">restoregrants<\/span> <span style=\"color:#f92672\">--<\/span><span style=\"color:#a6e22e\">cpuser<\/span>=<span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#a6e22e\">cpuser<\/span> <span style=\"color:#f92672\">--<\/span><span style=\"color:#a6e22e\">db<\/span>=<span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#66d9ef\">type<\/span>  <span style=\"color:#f92672\">--<\/span><span style=\"color:#a6e22e\">all<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>The examples above use the following variables:<\/p>\n<ul>\n<li><code>$cpuser<\/code> \u2014 The cPanel username who lost access to their databases.<\/li>\n<li><code>$dbuser<\/code> \u2014 The database user whose privileges to restore.\n<ul>\n<li>If you use the <code>--dbuser<\/code> flag, <code>$dbuser<\/code> represents the database user.<\/li>\n<li>If you use the <code>--all<\/code> flag, the script restores grants for all of the database users that belong to the cPanel account.<\/li>\n<\/ul>\n<\/li>\n<li><code>$type<\/code> \u2014 The type of database:\n<ul>\n<li><code>mysql<\/code> \u2014 MySQL\u00ae.<\/li>\n<li><code>pg<\/code> \u2014 PostgreSQL\u00ae.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"update-password\">Update password<\/h2>\n<p>In certain circumstances, the <code>restoregrants<\/code> script may fail to restore access to the database.<\/p>\n<p>If the script fails, either the cPanel user or the WHM user who owns the account (the reseller or system administrator) can reset the cPanel account\u2019s password to restore grants.<\/p>\n<p>The cPanel user can restore grants with the following steps:<\/p>\n<ol>\n<li>\n<p>Navigate to cPanel\u2019s <em>Password and Security<\/em><br \/>\ninterface (<em>cPanel &gt;&gt; Home &gt;&gt; Preferences &gt;&gt; Password &#038; Security<\/em>).<\/p>\n<\/li>\n<li>\n<p>Select <em>Allow MySQL password change<\/em>.<\/p>\n<\/li>\n<li>\n<p>Enter the old password in the <em>Old Password<\/em> text box.<\/p>\n<\/li>\n<li>\n<p>Enter a new password in the <em>New Password<\/em> and <em>New Password (again)<\/em> text boxes.<\/p>\n<\/li>\n<li>\n<p>Click <em>Change your password now<\/em>.<\/p>\n<\/li>\n<\/ol>\n<p>The server administrator or reseller can restore grants with the following steps:<\/p>\n<ol>\n<li>\n<p>Navigate to WHM\u2019s <em>List Accounts<\/em><br \/>\ninterface (<em>WHM &gt;&gt; Home &gt;&gt; Account Information &gt;&gt; List Accounts<\/em>).<\/p>\n<\/li>\n<li>\n<p>Click the <em>+<\/em> link next to the appropriate account.<\/p>\n<\/li>\n<li>\n<p>Select <em>Sync MySQL password with account password<\/em>.<\/p>\n<\/li>\n<li>\n<p>Enter a new password in the <em>Change Password<\/em> text box.<\/p>\n<\/li>\n<li>\n<p>Click <em>Change<\/em>.<\/p>\n<\/li>\n<\/ol><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview If a database user loses access to databases, you can restore the user\u2019s grants to the database with the restoregrants utility. The restoregrants script To use the restoregrants script to restore the user\u2019s database access, run one of the following commands from the command line: 1 2 \/usr\/local\/cpanel\/bin\/restoregrants &#8211;cpuser=$cpuser &#8211;db=$type &#8211;dbuser=$dbuser \/usr\/local\/cpanel\/bin\/restoregrants &#8211;cpuser=$cpuser &#8211;db=$type &hellip;<\/p>\n","protected":false},"author":1,"featured_media":394,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/393"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=393"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/393\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/394"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}