{"id":2518,"date":"2025-08-05T10:16:50","date_gmt":"2025-08-05T10:16:50","guid":{"rendered":"https:\/\/hostrago.com\/knowledge-base\/?p=2518"},"modified":"2025-08-05T10:16:51","modified_gmt":"2025-08-05T10:16:51","slug":"restore-database-access-users","status":"publish","type":"post","link":"https:\/\/hostrago.com\/knowledge-base\/restore-database-access-users\/","title":{"rendered":"How to Restore Database Access of Users?"},"content":{"rendered":"\n<p>If you&#8217;re managing your website on a cPanel hosting platform and suddenly your MySQL database becomes inaccessible for specific users, it&#8217;s likely due to incorrect privileges or broken database-user mappings. The need to <strong>restore database<\/strong> access is common\u2014especially after migrations, backup restorations, or accidental deletions. Ensuring your database users have the correct permissions is critical for seamless website operation.<\/p>\n\n\n\n<p>At <strong><a href=\"https:\/\/hostrago.com\/\">HostraGo<\/a><\/strong>, we often get queries from users trying to fix broken database connections or facing MySQL errors such as &#8220;Access denied for user.&#8221; This guide will walk you through simple yet effective ways to restore database access manually using <strong>cPanel<\/strong> or <strong>WHM<\/strong> tools. If you&#8217;re a web developer, site owner, or hosting provider, this blog will help you regain control and resolve access issues swiftly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Reasons Why Database Access is Lost<\/h2>\n\n\n\n<p>Before jumping into the solution, it&#8217;s important to understand <strong>why database access breaks<\/strong>. Common scenarios include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>restore database without associated database users<\/li>\n\n\n\n<li>Changing hosting provider without importing user privileges<\/li>\n\n\n\n<li>Deleting a user accidentally in cPanel<\/li>\n\n\n\n<li>Permission misconfiguration<\/li>\n\n\n\n<li>Incomplete database restoration process<\/li>\n<\/ul>\n\n\n\n<p>Knowing the cause can help you avoid the same issue in the future.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-restoregrants-script\">How to use the restoregrants script?<\/h2>\n\n\n\n<p>Run one of the following commands from the command line to use the\u00a0<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\"><em>restoregrants<\/em>\u00a0<\/mark>script to restore the user\u2019s database access:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/usr\/local\/cpanel\/bin\/restoregrants --cpuser=$cpuser --db=$type --dbuser=$dbuser\n\/usr\/local\/cpanel\/bin\/restoregrants --cpuser=$cpuser --db=$type  --all<\/pre>\n\n\n\n<p><strong>Description of the variables used in the above example:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>$cpuser<\/code>\u00a0\u2014 Refers to the cPanel username who lost their database access.<\/li>\n\n\n\n<li><code>$dbuser<\/code>\u00a0\u2014 The database user who can restore the database.\n<ul class=\"wp-block-list\">\n<li>If you use the\u00a0<code>--dbuser<\/code>\u00a0flag,\u00a0<code>$dbuser<\/code>\u00a0describe the database user.<\/li>\n\n\n\n<li>If you use the\u00a0<code>--all<\/code>\u00a0flag, the script restores permissions for all database users associated with the cPanel account.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>$type<\/code>\u00a0\u2014 Refers to the type of database:\n<ul class=\"wp-block-list\">\n<li><code>mysql<\/code>\u00a0\u2014 MySQL\u00ae.<\/li>\n\n\n\n<li><code>pg<\/code>\u00a0\u2014 PostgreSQL\u00ae.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">How to Use the Update Password Method?<\/h2>\n\n\n\n<p>If you do not have SSH\/root access, updating the <strong>MySQL user password<\/strong> from the <a href=\"https:\/\/cpanel.net\/\" target=\"_blank\" rel=\"noopener\">cPanel <\/a>interface is a simple workaround to re-sync user privileges.<\/p>\n\n\n\n<p>Below are two scenarios depending on your level of access.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">If You Are a cPanel User<\/h2>\n\n\n\n<p>Follow these steps to <strong>restore database<\/strong> access by updating the MySQL user password:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Login to your cPanel account.<\/strong><br>URL: <code>https:\/\/yourdomain.com:2083<\/code> or via your hosting provider (e.g., HostraGo Dashboard)<\/li>\n\n\n\n<li><strong>Go to \u201cMySQL Databases\u201d<\/strong> under the <strong>Databases<\/strong> section.<\/li>\n\n\n\n<li>Scroll down to <strong>Current Users<\/strong>.<\/li>\n\n\n\n<li>Locate the MySQL user having issues and click <strong>Change Password<\/strong> next to it.<\/li>\n\n\n\n<li>Enter a <strong>new strong password<\/strong> and confirm.<\/li>\n\n\n\n<li>Click <strong>Change Password<\/strong>.<\/li>\n\n\n\n<li>Ensure the MySQL user is added to the correct database in the \u201cAdd User to Database\u201d section.<\/li>\n\n\n\n<li>Click <strong>All Privileges<\/strong> > <strong>Make Changes<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p>This refreshes the user&#8217;s privileges and restores connectivity to the database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">If You Are a Server Administrator or a Reseller<\/h2>\n\n\n\n<p>You can follow these steps via <strong>WHM<\/strong> or manually through SSH\/cPanel access for your client accounts:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Login to WHM<\/strong> as root or reseller.<br>URL: <code>https:\/\/yourserverip:2087<\/code><\/li>\n\n\n\n<li>Navigate to <strong>List Accounts<\/strong> and choose the affected cPanel account.<\/li>\n\n\n\n<li>Click <strong>cPanel icon<\/strong> to log into the user\u2019s control panel.<\/li>\n\n\n\n<li>Go to <strong>MySQL Databases<\/strong> > Locate the user under \u201cCurrent Users\u201d.<\/li>\n\n\n\n<li>Click <strong>Change Password<\/strong>, set a new one, and save.<\/li>\n\n\n\n<li>Reassign the user to the database if needed (via \u201cAdd User to Database\u201d).<\/li>\n\n\n\n<li>Grant <strong>All Privileges<\/strong> to ensure full access.<\/li>\n\n\n\n<li>Confirm database connection by opening the website or testing via <code>phpMyAdmin<\/code>.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Why Is This Necessary?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>During migrations or restorations, the MySQL user gets recreated, but <strong>privileges are not auto-restored<\/strong> unless included in the backup.<\/li>\n\n\n\n<li>Changing the user password <strong>refreshes internal mapping<\/strong> in MySQL and cPanel, restoring access.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Final Thoughts<\/h2>\n\n\n\n<p>restore database access is a straightforward process once you understand the user-database relationship and privileges. With the right steps, tools, and guidance, you can regain access in minutes. If you&#8217;re managing multiple sites, automate backups and keep your credentials secure to avoid future issues.<\/p>\n\n\n\n<p>Trust <a href=\"https:\/\/hostrago.com\/\"><strong>HostraGo<\/strong> <\/a>for secure, fast, and reliable web hosting services with tools that make database management easier than ever!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re managing your website on a cPanel hosting platform and suddenly your MySQL database becomes inaccessible for specific users, it&#8217;s likely due to incorrect&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2517,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[752,749,751,423,649,750,753],"class_list":["post-2518","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-whm","tag-cpanel-mysql-user","tag-database-access-issue","tag-fix-database-permission","tag-hostrago-support","tag-mysql-privileges","tag-restore-database","tag-whm-database-restore"],"menu_order":0,"_links":{"self":[{"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=2518"}],"version-history":[{"count":1,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2518\/revisions"}],"predecessor-version":[{"id":2519,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2518\/revisions\/2519"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/media\/2517"}],"wp:attachment":[{"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=2518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=2518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=2518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}