{"id":2219,"date":"2015-09-02T12:28:33","date_gmt":"2015-09-02T12:28:33","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=2219"},"modified":"2015-09-02T12:29:13","modified_gmt":"2015-09-02T12:29:13","slug":"2219","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=2219","title":{"rendered":"HOW TO RESET A FORGOTTEN ROOT PASSWORD FOR MARIADB ON CENTOS 7"},"content":{"rendered":"<header class=\"entry-header\">\n<p class=\"entry-title\">Lost your MariaDB root password? Well, you\u2019re in luck because this brief tutorial is going to show you how get into the database server and create a new root password.<\/p>\n<\/header>\n<div class=\"entry-content\">\n<p>When you forget the root password for MariaDB database server, you can\u2019t just unlock or recover it, you must create a new and different one. To do this you need root privileges on the server you\u2019re running MariaDB\u00a0database server on. Then you need to use a\u00a0backdoor trick that most people use to the reset forgotten root password for MySQL or MariaDB database server.<\/p>\n<p>So, if you\u2019ve forgotten your password to sign on MariaDB server, continue below.<\/p>\n<p>This first thing you need to do is stop the database server. Obviously your site will be down, but this is the only way to access the backdoor of the server to reset the password. To stop or shutdown MariaDB on CentOS 7, run the commands below.<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">sudo systemctl stop mariadb.service<\/div><\/div>\n\n<\/pre>\n<p>&nbsp;<\/p>\n<p>On Ubuntu run the commands below<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">sudo service mariadb stop<\/div><\/div>\n\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Next, you need to start MariaDB with unrestricted access so you wouldn\u2019t need password to sign on as the root user. This starts the database server in an insecure manner keeping it wide open to anyone.<\/p>\n<p>Because the database is left wide open, you should safeguard against someone logging into the database remotely. This could happen, so add the <strong>\u2013skip-networking<\/strong> option to the commands.<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">sudo mysqld_safe --skip-grant-tables --skip-networking &amp;amp;<\/div><\/div>\n\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Now that the database is started, you can now logon to it without passwords. Run the commands below to sign on to the database without prompting for password.<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">mysql -u root<\/div><\/div>\n\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Once you\u2019re logged-on, change to the <strong>mysql database<\/strong>. This database comes with all MySQL and MariaDB servers. It\u2019s store encrypted credentials and privileges for the root user.<\/p>\n<p>To change to the mysql database, run the commands below.<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">use mysql;<\/div><\/div>\n\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Next, run the commands below to change the root password<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">update user set password=PASSWORD(&quot;&lt;i&gt;new-password&lt;\/i&gt;&quot;) where User='root';<\/div><\/div>\n\n<\/pre>\n<p>Remember to replace <strong>new-password<\/strong> with the root password and press Enter.<\/p>\n<p>Then run the commands below to flush or reset the privileges table.<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">flush privileges;<\/div><\/div>\n\n<\/pre>\n<p>Exit.<\/p>\n<p>Now that the root password is changed, you should now be able to stop\/start MariaDB server normally and and logon as the root user using the new password you created above.<\/p>\n<p>You can stop, then start the server using the commands below<\/p>\n<p>To stop the database, run the commands below.<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">sudo systemctl stop mariadb.service<\/div><\/div>\n\n<\/pre>\n<p>To start, run the commands below<\/p>\n<p>sudo systemctl start mariadb.service<\/p>\n<p>&nbsp;<\/p>\n<p>Then logon as the root user with the new password using the commands below. W<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">mysql -u root -p<\/div><\/div>\n\n<\/pre>\n<p>That\u2019s it! \u00a0This is how you reset or re-created forgotten root password for MariaDB database server.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Lost your MariaDB root password? Well, you\u2019re in luck because this brief tutorial is going to show you how get into the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2219","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2219"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2219\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}