{"id":189,"date":"2026-05-31T23:05:57","date_gmt":"2026-06-01T06:05:57","guid":{"rendered":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/"},"modified":"2026-05-31T23:05:57","modified_gmt":"2026-06-01T06:05:57","slug":"how-to-reset-mysql-root-password","status":"publish","type":"post","link":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/","title":{"rendered":"How to Reset MySQL Root Password on Linux (MySQL 8 &amp; MariaDB)"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>Losing MySQL root access is one of those problems that feels catastrophic but is usually fixable in under ten minutes. A MySQL password reset is needed when you&#8217;ve inherited a server without credentials, migrated to a new VPS, or simply haven&#8217;t logged in for months and can&#8217;t remember what you set. It&#8217;s also common after restoring a snapshot or provisioning a new Host &amp; Tech <a href=\"https:\/\/www.hostandtech.com\/vps-ssd-servers\">VPS SSD Hosting<\/a> instance where the MySQL root password was never explicitly set.<\/p>\n<p>The process differs slightly between MySQL 8.0+ and MariaDB 10.x, and it differs again depending on whether your distribution uses socket-based authentication for root \u2014 which Ubuntu 20.04, 22.04, and 24.04 do by default. If you skip that detail, the reset appears to work but you still can&#8217;t log in with a password. This guide covers both cases.<\/p>\n<p>These steps apply to self-managed Linux servers (Ubuntu, Debian, AlmaLinux\/CentOS). If you&#8217;re on managed WordPress hosting or a cPanel environment, your MySQL credentials are handled differently \u2014 check the cPanel MySQL Databases interface first before going this route.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>SSH access to the server with <strong>sudo<\/strong> or root privileges<\/li>\n<li>MySQL 8.0+ or MariaDB 10.3+ installed (these steps don&#8217;t apply to MySQL 5.7 <code class=\"\" data-line=\"\">--skip-grant-tables<\/code> flow exactly as written \u2014 see the note in Step 2)<\/li>\n<li>Ability to stop and restart the MySQL\/MariaDB service (requires root or sudo)<\/li>\n<li>A terminal client \u2014 PuTTY, Windows Terminal, or any SSH client works fine<\/li>\n<li>2\u20135 minutes of downtime tolerance \u2014 MySQL must be stopped briefly during the reset<\/li>\n<\/ul>\n<h2>Step-by-Step: Reset the MySQL Root Password<\/h2>\n<h3>Step 1 \u2014 Check Which Database Server You&#8217;re Running<\/h3>\n<p>Before anything else, confirm whether you&#8217;re on MySQL or MariaDB. The commands are slightly different.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-1\"><code class=\"\" data-line=\"\">mysql --version<\/code><\/pre>\n<\/div>\n<p>You&#8217;ll see something like <code class=\"\" data-line=\"\">mysql  Ver 8.0.36<\/code> or <code class=\"\" data-line=\"\">mysql  Ver 15.1 Distrib 10.6.16-MariaDB<\/code>. Note this \u2014 you&#8217;ll need it in Step 4.<\/p>\n<h3>Step 2 \u2014 Stop the MySQL Service<\/h3>\n<p>You need to stop MySQL so you can restart it without authentication checks.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-2\"><code class=\"\" data-line=\"\">sudo systemctl stop mysql\n# or on AlmaLinux\/CentOS:\nsudo systemctl stop mysqld<\/code><\/pre>\n<\/div>\n<p>Confirm it stopped:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-3\"><code class=\"\" data-line=\"\">sudo systemctl status mysql<\/code><\/pre>\n<\/div>\n<p>You should see <code class=\"\" data-line=\"\">inactive (dead)<\/code>. If it won&#8217;t stop cleanly, check for active connections with <code class=\"\" data-line=\"\">sudo ss -tp | grep mysql<\/code> and kill them first.<\/p>\n<h3>Step 3 \u2014 Start MySQL in Safe Mode (Skip Grant Tables)<\/h3>\n<p>This starts MySQL without loading the permission system, which lets you log in without a password. The method changed in MySQL 8 \u2014 the old <code class=\"\" data-line=\"\">--skip-grant-tables<\/code> alone isn&#8217;t sufficient. Use the init-file approach for MySQL 8, or the direct flag for MariaDB.<\/p>\n<p><strong>For MySQL 8.0+:<\/strong><\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-4\"><code class=\"\" data-line=\"\"># Create a temporary SQL init file\nsudo mkdir -p \/var\/lib\/mysql-reset\nsudo tee \/var\/lib\/mysql-reset\/reset.sql &lt;&lt; &#039;EOF&#039;\nALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED WITH mysql_native_password BY &#039;YourNewSecurePassword123!&#039;;\nEOF\n\n# Start MySQL using that init file\nsudo mysqld --user=mysql --init-file=\/var\/lib\/mysql-reset\/reset.sql &amp;<\/code><\/pre>\n<\/div>\n<p>Wait 5\u201310 seconds for MySQL to start and process the file. Then stop it and clean up:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-5\"><code class=\"\" data-line=\"\">sudo kill $(sudo cat \/var\/run\/mysqld\/mysqld.pid)\nsudo rm -rf \/var\/lib\/mysql-reset<\/code><\/pre>\n<\/div>\n<p><strong>For MariaDB 10.x:<\/strong><\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-6\"><code class=\"\" data-line=\"\">sudo mysqld_safe --skip-grant-tables --skip-networking &amp;<\/code><\/pre>\n<\/div>\n<p>The <code class=\"\" data-line=\"\">--skip-networking<\/code> flag is there for a reason: it prevents remote connections while the server has no authentication. Don&#8217;t skip it.<\/p>\n<p>\ud83d\udcdd Note: On MySQL 5.7 (older servers), the original <code class=\"\" data-line=\"\">--skip-grant-tables<\/code> method still works, but MySQL 5.7 is end-of-life. If you&#8217;re still running it, I&#8217;d strongly recommend upgrading before this becomes a bigger problem.<\/p>\n<h3>Step 4 \u2014 Log In and Set the New Password<\/h3>\n<p><strong>For MySQL 8.0+ (if you used the init-file method above):<\/strong><\/p>\n<p>MySQL should already have processed the password change. Restart the service normally and test:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-7\"><code class=\"\" data-line=\"\">sudo systemctl start mysql\nmysql -u root -p<\/code><\/pre>\n<\/div>\n<p>Enter the password you set in the <code class=\"\" data-line=\"\">reset.sql<\/code> file. If you get in, you&#8217;re done. Skip to Step 5.<\/p>\n<p><strong>For MariaDB (skip-grant-tables method):<\/strong><\/p>\n<p>Connect without a password:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-8\"><code class=\"\" data-line=\"\">mysql -u root<\/code><\/pre>\n<\/div>\n<p>Then run:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-9\"><code class=\"\" data-line=\"\">FLUSH PRIVILEGES;\nALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;YourNewSecurePassword123!&#039;;\nEXIT;<\/code><\/pre>\n<\/div>\n<p>Now stop the safe-mode instance and start MySQL normally:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-10\"><code class=\"\" data-line=\"\">sudo kill $(sudo cat \/var\/run\/mysqld\/mysqld.pid 2&gt;\/dev\/null || pgrep mysqld)\nsudo systemctl start mysql\nmysql -u root -p<\/code><\/pre>\n<\/div>\n<p>\u26a0 Warning: Replace <code class=\"\" data-line=\"\">YourNewSecurePassword123!<\/code> with an actual strong password before running any of these commands. Never leave a literal example password on a production server.<\/p>\n<h3>Step 5 \u2014 Handle Socket Authentication (Ubuntu-Specific Gotcha)<\/h3>\n<p>This is the part official docs gloss over. On Ubuntu 20.04, 22.04, and 24.04, MySQL root defaults to the <code class=\"\" data-line=\"\">auth_socket<\/code> plugin \u2014 meaning it authenticates by your Linux username, not a password. So even after a reset, <code class=\"\" data-line=\"\">mysql -u root -p<\/code> may still fail if the plugin wasn&#8217;t changed.<\/p>\n<p>Check what auth plugin is set:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-11\"><code class=\"\" data-line=\"\">SELECT user, host, plugin FROM mysql.user WHERE user = &#039;root&#039;;<\/code><\/pre>\n<\/div>\n<p>If you see <code class=\"\" data-line=\"\">auth_socket<\/code> or <code class=\"\" data-line=\"\">unix_socket<\/code> in the plugin column, run this to switch to password authentication:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-12\"><code class=\"\" data-line=\"\">ALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED WITH mysql_native_password BY &#039;YourNewSecurePassword123!&#039;;\nFLUSH PRIVILEGES;\nEXIT;<\/code><\/pre>\n<\/div>\n<p>\ud83d\udcdd Note: On MySQL 8.0.34+, <code class=\"\" data-line=\"\">mysql_native_password<\/code> is deprecated and disabled by default in MySQL 8.4. If you&#8217;re on MySQL 8.4, use <code class=\"\" data-line=\"\">caching_sha2_password<\/code> instead, or enable the native plugin explicitly in <code class=\"\" data-line=\"\">\/etc\/mysql\/mysql.conf.d\/mysqld.cnf<\/code>.<\/p>\n<h3>Step 6 \u2014 Re-run mysql_secure_installation (Optional but Recommended)<\/h3>\n<p>If this is a fresh server and you haven&#8217;t hardened MySQL yet, now&#8217;s a good time:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-13\"><code class=\"\" data-line=\"\">sudo mysql_secure_installation<\/code><\/pre>\n<\/div>\n<p>\u26a0 Warning: If root is still using socket auth, <code class=\"\" data-line=\"\">mysql_secure_installation<\/code> will throw an error or behave unexpectedly. Complete Step 5 first, then run this.<\/p>\n<h2>Common Issues &amp; Troubleshooting<\/h2>\n<h3>ERROR 1698 (28000): Access denied for user &#8216;root&#8217;@&#8217;localhost&#8217;<\/h3>\n<p>This is the socket auth issue described in Step 5. You&#8217;re connecting with a password but MySQL is expecting OS-level authentication. Log in via <code class=\"\" data-line=\"\">sudo mysql<\/code> (no password flag), then switch the auth plugin as shown in Step 5.<\/p>\n<h3>mysqld: Can&#8217;t create\/write to file &#8216;\/var\/lib\/mysql-reset\/reset.sql&#8217;<\/h3>\n<p>Permission problem. Make sure you&#8217;re using <code class=\"\" data-line=\"\">sudo tee<\/code> rather than a redirect with your regular user. The MySQL process runs as the <code class=\"\" data-line=\"\">mysql<\/code> user \u2014 the init file path needs to be readable by it. <code class=\"\" data-line=\"\">\/tmp<\/code> works as an alternative path if you&#8217;re stuck.<\/p>\n<h3>MySQL won&#8217;t start after the reset attempt<\/h3>\n<p>Usually caused by a leftover PID file or a crashed safe-mode instance still holding the socket. Check:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-14\"><code class=\"\" data-line=\"\">sudo rm -f \/var\/run\/mysqld\/mysqld.pid\nsudo rm -f \/var\/run\/mysqld\/mysqld.sock\nsudo systemctl start mysql<\/code><\/pre>\n<\/div>\n<p>If it still won&#8217;t start, check the error log:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-15\"><code class=\"\" data-line=\"\">sudo tail -50 \/var\/log\/mysql\/error.log<\/code><\/pre>\n<\/div>\n<h3>mysql_native_password plugin not found (MySQL 8.4)<\/h3>\n<p>MySQL 8.4 ships with <code class=\"\" data-line=\"\">mysql_native_password<\/code> disabled. Either use <code class=\"\" data-line=\"\">caching_sha2_password<\/code> in your <code class=\"\" data-line=\"\">ALTER USER<\/code> statement, or re-enable the legacy plugin by adding <code class=\"\" data-line=\"\">mysql_native_password=ON<\/code> under <code class=\"\" data-line=\"\">[mysqld]<\/code> in your config file and restarting.<\/p>\n<h3>Password reset worked but phpMyAdmin still shows Access Denied<\/h3>\n<p>phpMyAdmin caches credentials in its config file. Check <code class=\"\" data-line=\"\">\/etc\/phpmyadmin\/config.inc.php<\/code> or your custom phpMyAdmin config and update the <code class=\"\" data-line=\"\">$cfg[&#039;Servers&#039;][$i][&#039;password&#039;]<\/code> value. Also clear any browser session cookies \u2014 phpMyAdmin&#8217;s session handling will hold onto a failed auth state.<\/p>\n<h2>Frequently Asked Questions<\/h2>\n<div class=\"ht-faq-section\">\n<h2>Frequently Asked Questions<\/h2>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Can I reset the MySQL root password without restarting MySQL?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Only if you have another MySQL account with SUPER or SYSTEM_USER privileges. If you do, log in with that account and run ALTER USER &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;newpassword&#8217;; followed by FLUSH PRIVILEGES;. If root is your only admin account and you&#8217;re locked out, a service restart is unavoidable.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Will resetting the root password affect my databases or WordPress site?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>No \u2014 resetting root doesn&#8217;t touch your actual database data. Your WordPress site connects using its own database user (usually defined in wp-config.php), not root. Just don&#8217;t change the WordPress database user&#8217;s password unless you update wp-config.php at the same time.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">How do I reset the MySQL password in cPanel\/WHM?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>In WHM, go to SQL Services &gt; MySQL Root Password and set a new one from there. Don&#8217;t use the Linux command-line method on cPanel servers \u2014 WHM manages its own MySQL config and doing it manually can cause sync issues with cPanel&#8217;s internal credential store.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">What&#039;s the difference between MySQL root and Linux root for this process?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>They&#8217;re completely separate. Linux root is your operating system superuser \u2014 it&#8217;s what lets you run sudo commands. MySQL root is a database-level account that only exists inside MySQL. You need Linux root (or sudo) access to perform the reset, but the MySQL root password itself is its own credential.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Is it safe to use &#8211;skip-grant-tables on a production server?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Only briefly, and always with &#8211;skip-networking enabled at the same time. Without networking, no external connections can reach MySQL while it&#8217;s in this unprotected state. Never leave MySQL running in skip-grant-tables mode \u2014 get in, change the password, and restart normally as fast as possible.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Locked out of MySQL? It happens more than you&#8217;d think \u2014 especially after a fresh VPS setup or a server migration. This guide walks you through resetting the MySQL root password on MySQL 8 and MariaDB, covering socket auth quirks that trip up most people the first time.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[59],"tags":[229,433,54,287,52,435,432,434],"class_list":["post-189","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-cpanel-mysql","tag-database-access","tag-linux-server","tag-mariadb","tag-mysql","tag-mysql-password-reset","tag-mysql-root-password","tag-vps-database"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Reset MySQL Root Password on Linux (MySQL 8 &amp; MariaDB)<\/title>\n<meta name=\"description\" content=\"Lost your MySQL root password? This guide covers MySQL password reset for MySQL 8 and MariaDB on Ubuntu, Debian, and CentOS\/AlmaLinux \u2014 including socket auth fixes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Reset MySQL Root Password on Linux (MySQL 8 &amp; MariaDB)\" \/>\n<meta property=\"og:description\" content=\"Lost your MySQL root password? This guide covers MySQL password reset for MySQL 8 and MariaDB on Ubuntu, Debian, and CentOS\/AlmaLinux \u2014 including socket auth fixes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/\" \/>\n<meta property=\"og:site_name\" content=\"Host And Tech knowledge base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/stshostandtech\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-01T06:05:57+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:site\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\"},\"headline\":\"How to Reset MySQL Root Password on Linux (MySQL 8 &amp; MariaDB)\",\"datePublished\":\"2026-06-01T06:05:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/\"},\"wordCount\":1242,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"keywords\":[\"cPanel mysql\",\"database access\",\"Linux server\",\"mariadb\",\"MySQL\",\"MySQL password reset\",\"mysql root password\",\"VPS database\"],\"articleSection\":[\"MySQL &amp; MariaDB\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/\",\"name\":\"How to Reset MySQL Root Password on Linux (MySQL 8 & MariaDB)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\"},\"datePublished\":\"2026-06-01T06:05:57+00:00\",\"description\":\"Lost your MySQL root password? This guide covers MySQL password reset for MySQL 8 and MariaDB on Ubuntu, Debian, and CentOS\\\/AlmaLinux \u2014 including socket auth fixes.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-reset-mysql-root-password\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Reset MySQL Root Password on Linux (MySQL 8 &amp; MariaDB)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"name\":\"Host And Tech knowledge base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\",\"name\":\"Host And Tech knowledge base\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"contentUrl\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"width\":1134,\"height\":395,\"caption\":\"Host And Tech knowledge base\"},\"image\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/stshostandtech\",\"https:\\\/\\\/x.com\\\/stshostandtech\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/hostandtech.com\\\/kb\"],\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/author\\\/admin_fjj7qydm\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Reset MySQL Root Password on Linux (MySQL 8 & MariaDB)","description":"Lost your MySQL root password? This guide covers MySQL password reset for MySQL 8 and MariaDB on Ubuntu, Debian, and CentOS\/AlmaLinux \u2014 including socket auth fixes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/","og_locale":"en_US","og_type":"article","og_title":"How to Reset MySQL Root Password on Linux (MySQL 8 & MariaDB)","og_description":"Lost your MySQL root password? This guide covers MySQL password reset for MySQL 8 and MariaDB on Ubuntu, Debian, and CentOS\/AlmaLinux \u2014 including socket auth fixes.","og_url":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/","og_site_name":"Host And Tech knowledge base","article_publisher":"https:\/\/www.facebook.com\/stshostandtech","article_published_time":"2026-06-01T06:05:57+00:00","author":"admin","twitter_card":"summary_large_image","twitter_creator":"@stshostandtech","twitter_site":"@stshostandtech","twitter_misc":{"Written by":"admin","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/#article","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/"},"author":{"name":"admin","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee"},"headline":"How to Reset MySQL Root Password on Linux (MySQL 8 &amp; MariaDB)","datePublished":"2026-06-01T06:05:57+00:00","mainEntityOfPage":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/"},"wordCount":1242,"commentCount":0,"publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"keywords":["cPanel mysql","database access","Linux server","mariadb","MySQL","MySQL password reset","mysql root password","VPS database"],"articleSection":["MySQL &amp; MariaDB"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/","url":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/","name":"How to Reset MySQL Root Password on Linux (MySQL 8 & MariaDB)","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/#website"},"datePublished":"2026-06-01T06:05:57+00:00","description":"Lost your MySQL root password? This guide covers MySQL password reset for MySQL 8 and MariaDB on Ubuntu, Debian, and CentOS\/AlmaLinux \u2014 including socket auth fixes.","breadcrumb":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-reset-mysql-root-password\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hostandtech.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to Reset MySQL Root Password on Linux (MySQL 8 &amp; MariaDB)"}]},{"@type":"WebSite","@id":"https:\/\/hostandtech.com\/kb\/#website","url":"https:\/\/hostandtech.com\/kb\/","name":"Host And Tech knowledge base","description":"","publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hostandtech.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hostandtech.com\/kb\/#organization","name":"Host And Tech knowledge base","url":"https:\/\/hostandtech.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","contentUrl":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","width":1134,"height":395,"caption":"Host And Tech knowledge base"},"image":{"@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/stshostandtech","https:\/\/x.com\/stshostandtech"]},{"@type":"Person","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/hostandtech.com\/kb"],"url":"https:\/\/hostandtech.com\/kb\/author\/admin_fjj7qydm\/"}]}},"_links":{"self":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":0,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"wp:attachment":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}