{"id":257,"date":"2024-10-27T10:57:14","date_gmt":"2024-10-27T05:27:14","guid":{"rendered":"https:\/\/griffso.com\/blogs\/?p=257"},"modified":"2024-10-27T10:57:33","modified_gmt":"2024-10-27T05:27:33","slug":"reset-mysql-root-password","status":"publish","type":"post","link":"https:\/\/griffso.com\/blogs\/reset-mysql-root-password\/","title":{"rendered":"Reset MySQL Root Password in XAMPP"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">How to Reset MySQL Root Password in XAMPP and Fix Table Corruption Issues<\/h1>\n\n\n\n<p>If you&#8217;re using XAMPP and encounter access issues with your MySQL database, it may be necessary to reset your root password or address table corruption. This guide will walk you through both processes step by step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Stop the MySQL Service<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Open XAMPP Control Panel<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Locate the XAMPP Control Panel and open it.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Stop MySQL<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on the &#8220;Stop&#8221; button next to MySQL.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Open Command Prompt as Administrator<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Search for Command Prompt<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Type &#8220;cmd&#8221; in the Windows search bar.<\/li>\n\n\n\n<li>Right-click on &#8220;Command Prompt&#8221; and select &#8220;Run as administrator&#8221;.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Navigate to the MySQL Bin Directory<\/h2>\n\n\n\n<p>In the command prompt, navigate to the MySQL bin directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd C:\\xampp\\mysql\\bin<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Start MySQL in Safe Mode<\/h2>\n\n\n\n<p>To allow access without password checks, run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqld --skip-grant-tables<\/code><\/pre>\n\n\n\n<p>Keep this command prompt open. You should see messages indicating that MySQL is running.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Open Another Command Prompt<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Open a New Command Prompt<\/strong> (do not close the one running <code>mysqld<\/code>).<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Log into MySQL<\/h2>\n\n\n\n<p>In the new command prompt, type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root<\/code><\/pre>\n\n\n\n<p>You should now have access to the MySQL prompt without a password.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Update the Root Password<\/h2>\n\n\n\n<p>Once logged in, update the root password using the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FLUSH PRIVILEGES;\nALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';<\/code><\/pre>\n\n\n\n<p>Replace <code>new_password<\/code> with your desired password.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8: Exit MySQL<\/h2>\n\n\n\n<p>To log out of MySQL, type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>exit;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 9: Stop the Safe Mode MySQL<\/h2>\n\n\n\n<p>Go back to the command prompt running <code>mysqld<\/code> and stop it (you can close that command prompt).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 10: Start MySQL Normally<\/h2>\n\n\n\n<p>Return to the XAMPP Control Panel and start the MySQL service again.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 11: Test the New Password<\/h2>\n\n\n\n<p>Open a new command prompt and test the new password:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p<\/code><\/pre>\n\n\n\n<p>Enter the new password you set.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 12: Fixing Table Corruption Issues<\/h2>\n\n\n\n<p>If you encounter an error like <code>Got error 176 \"Read page with wrong checksum\" from storage engine Aria<\/code>, follow these steps to address table corruption:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">12.1. Check for Table Corruption<\/h3>\n\n\n\n<p>First, check for corruption by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CHECK TABLE `table_name`;  -- Replace `table_name` with your table<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">12.2. Repair Corrupted Tables<\/h3>\n\n\n\n<p>If corruption is detected, repair the table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>REPAIR TABLE `table_name`;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">12.3. Use myisamchk (for MyISAM Tables)<\/h3>\n\n\n\n<p>If your tables use the MyISAM engine, you can use <code>myisamchk<\/code>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Stop MySQL<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the XAMPP Control Panel to stop the MySQL service.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Open Command Prompt<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Navigate to the MySQL data directory:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>   cd C:\\xampp\\mysql\\data<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Run myisamchk<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   myisamchk -r *.MYI<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Restart MySQL<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start the MySQL service from the XAMPP Control Panel.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>By following these steps, you can reset your MySQL root password and address any corruption issues in your database tables. Regular backups are essential to prevent data loss. If you continue to face issues, consider reinstalling XAMPP or further investigating the specific errors.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<div class=\"pld-like-dislike-wrap pld-template-1\">\n    <div class=\"pld-like-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"257\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\n                        <i class=\"fas fa-thumbs-up\"><\/i>\n                <\/a>\n    <span class=\"pld-like-count-wrap pld-count-wrap\">1    <\/span>\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0)\" class=\"pld-dislike-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"257\" data-trigger-type=\"dislike\" data-restriction=\"cookie\" data-already-liked=\"0\">\n                        <i class=\"fas fa-thumbs-down\"><\/i>\n                <\/a>\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>How to Reset MySQL Root Password in XAMPP and Fix Table Corruption Issues If you&#8217;re using XAMPP and encounter access issues with your MySQL database, it may be necessary to reset your root password or address table corruption. This guide will walk you through both processes step by step. Step 1: Stop the MySQL Service [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-257","post","type-post","status-publish","format-standard","hentry","category-coding-help-programming-tips-code-examples-coding-resources-debug-guide-software-development-learn-to-code-coding-best-practices-coding-challenges-coding-tutorials"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/posts\/257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/comments?post=257"}],"version-history":[{"count":2,"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/posts\/257\/revisions"}],"predecessor-version":[{"id":259,"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/posts\/257\/revisions\/259"}],"wp:attachment":[{"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/media?parent=257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/categories?post=257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griffso.com\/blogs\/wp-json\/wp\/v2\/tags?post=257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}