{"id":672,"date":"2018-09-17T05:19:49","date_gmt":"2018-09-17T02:19:49","guid":{"rendered":"http:\/\/kifarunix.com\/?p=672"},"modified":"2024-03-11T19:41:48","modified_gmt":"2024-03-11T16:41:48","slug":"a-simple-way-to-reset-mysql-mariadb-root-password","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/a-simple-way-to-reset-mysql-mariadb-root-password\/","title":{"rendered":"A Simple Way to Reset MySQL\/MariaDB root Password"},"content":{"rendered":"\n<p>In this guide, we are going to learn a simple way to reset MySQL\/MariaDB root password just in case you have lost, forgotten or just want to change it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resetting MySQL\/MariaDB Root Password<\/h2>\n\n\n\n<p>To reset reset MySQL\/MariaDB root password, step through the following;<\/p>\n\n\n\n<p><strong>NOTE: <\/strong>You must execute the following commands as root or with sudo privileges.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Stop MariaDB\/MySQL Service<\/h3>\n\n\n\n<p>Login to the server hosting DB and stop DB service with either of the he following commands;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl stop mariadb<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl stop mysql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Restart the Database in a safe mode<\/h3>\n\n\n\n<p>Start the database in safe mode using the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysqld_safe --skip-grant-tables --skip-networking &amp;<\/code><\/pre>\n\n\n\n<p>This bypasses authentication processes and disable any connection to database. Hence you can login to database without password.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Login to Database<\/h3>\n\n\n\n<p>Login to database as root using either of the following commands;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql<\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql -u root<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Reset MariaDB\/MySQL root Password<\/h3>\n\n\n\n<p>Once you are logged in to database, run the command below to reload grant tables and reset root password.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>FLUSH PRIVILEGES;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>update mysql.user set password=PASSWORD(\"<strong>StrongPASSW0rd<\/strong>\") where user='root';<\/code><\/pre>\n\n\n\n<p>Reload grant tables and exit.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>FLUSH PRIVILEGES;\nquit<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Stop the Database Service<\/h3>\n\n\n\n<p>Since the database service was launched to run in background in order to reset password, run the command below to safely stop it. This will prompt you to enter the new password set above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysqladmin -u root -p shutdown<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Start the Database Service<\/h3>\n\n\n\n<p>Now that all is done, you can now start the database normally.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl start mariadb<\/code><\/pre>\n\n\n\n<p>You have successfully reset MySQL\/MariaDB root password and can now access the database with all administrative rights.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we are going to learn a simple way to reset MySQL\/MariaDB root password just in case you have lost, forgotten or just<\/p>\n","protected":false},"author":1,"featured_media":16654,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121],"tags":[136,6691,135,6692,137],"class_list":["post-672","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-mariadb","tag-mariadb-reset-root-password","tag-mysql","tag-mysql-reset-root-password","tag-mysql-root-password","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/672"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=672"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/672\/revisions"}],"predecessor-version":[{"id":20989,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/672\/revisions\/20989"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/16654"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}