• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

LinuxSec Blog

Linux Tutorial for Beginners

  • About Me
  • Categories
  • Linux Blog
  • Hacker News
  • Geekbench
You are here: Home / CentOS / How to Reset MariaDB Root Password on CentOS 7

How to Reset MariaDB Root Password on CentOS 7

August 5, 2019 by Jack Wilder Leave a Comment

How to Reset MariaDB Root Password on CentOS 7. Today i logged in into my testing server (server for testing and learning, not my production server) because i want to test some server configuration. And because i am long time not login to this server, i am forgot my MariaDB password *lol. So, today i will show you how to reset MariaDB or MySQL database password.

If you have same problem as me (forgot mysql password), don’t worry, you can reset it if you have root or sudo access to your server.

First, you need to stop MariaDB process with this command

sudo service mariadb stop

Then run the service with safe mode command

sudo mysqld_safe --skip-grant-tables &

Now, you can login to your MariaDB without password

mysql -u root -p

Then, you can reset the password MariaDB password with this following command

use mysql;
update user SET PASSWORD=PASSWORD("password") WHERE USER='root';
flush privileges;
exit

Obviously you need to replace “password” with strong password.

After exit from MariaDB client, you need to kill all database process.

pkill -f 'mysql'

Then, restart MariaDB

sudo service mariadb restart

Now, you can login with your new password

[[email protected] ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

That’s it. Hope this solution will help to fix your problem.

Shares

Filed Under: CentOS






Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Random Post

BugBountyScanner – Script and Docker Image for Reconnaissance

2 Comments

Doing OSINT on Twitter using Tinfoleak

Leave a Comment

The Future Plan for This Blog

Leave a Comment

How to Enable REMI Repository in CentOS 8

Leave a Comment

How to Install Python Pip on CentOS 7

Leave a Comment

Ads


Powered by WordPress and Genesis Framework. Style by LinuxSec.