Mystery Data
  • Home
  • Tutorials
    • WordPress
    • Linux
    • Centos
    • MySQL/MariaDB
  • Control Panel
    • CWP
    • Vesta CP
  • Contact Me
  • Privacy Policy

Mystery Data

  • Home
  • Tutorials
    • WordPress
    • Linux
    • Centos
    • MySQL/MariaDB
  • Control Panel
    • CWP
    • Vesta CP
  • Contact Me
  • Privacy Policy
CentosLinuxMySQL

How to Reset and Recover MySQL or MariaDB Root Password on SystemD Linux

by Sandy November 29, 2017
written by Sandy November 29, 2017

This article will come in handy. We will explain how to reset or recover forgottent MySQL or MariaDB root password in Linux. If you forgot root password for your MySQL database server running under Linux, there is still a way to reset mysql root password using this commands. In order to recover the password, you simply have to follow these steps:

1. Stop mysql:

systemctl stop mysqld

2. Set the mySQL environment option

systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. Start mysql usig the options you just set

systemctl start mysqld

4. Login as root

mysql -u root

5. Update the root user password with these mysql commands

mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

replace MyNewPassword with actual password

6. Stop mysql

systemctl stop mysqld

7. Unset the mySQL envitroment option so it starts normally next time

systemctl unset-environment MYSQLD_OPTS

8. Start mysql normally:

systemctl start mysqld

Now Try to login using your new password:

mysql -u root -p

If this post helps you in any way please consider a donation

md-donate
0 comment
0
FacebookTwitterGoogle +Pinterest
next post
How to Enable HTTP/2 on CWP7 – Centos Web Panel

You may also like

How to Upgrade PHP 5.6 to PHP 7.3...

December 29, 2018

How to Install/build PHP 7.3 manually on CWP...

December 29, 2018

Update/Upgrade to MariaDB 10.3 on VestaCP/CWP/CentOS 7

September 8, 2018

Upgrade/Update to Latest Version of TeamSpeak 3 in...

September 1, 2018

Increase Import/Upload limit for phpMyAdmin and File Manager...

August 27, 2018

How to Enable HTTP/2 for Apache in CWP...

August 17, 2018

How to Configure/Install Let’s Encrypt SSL on VestaCP...

August 12, 2018

How to Install CyberPanel – OpenLiteSpeed Control Panel...

July 24, 2018

How to Install Memcached and Redis PHP Extensions...

July 23, 2018

How to Enable open_basedir with suPHP globally and...

July 21, 2018

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

md-donate

Recent Posts

  • How to Upgrade PHP 5.6 to PHP 7.3 on CentOS VestaCP
  • How to Install/build PHP 7.3 manually on CWP – Centos Web Panel
  • Update/Upgrade to MariaDB 10.3 on VestaCP/CWP/CentOS 7
  • Upgrade/Update to Latest Version of TeamSpeak 3 in CWP
  • Increase Import/Upload limit for phpMyAdmin and File Manager in CWP
  • How to Enable HTTP/2 for Apache in CWP with mod_http2 module
  • How to Configure/Install Let’s Encrypt SSL on VestaCP Mail Server and Vesta Admin – CentOS and Ubuntu
  • How to Install CyberPanel – OpenLiteSpeed Control Panel on Centos 7
  • How to Install Memcached and Redis PHP Extensions with Php Selector 5.6/7.0/7.1/7.2 CWP- Centos WebPanel
  • How to Enable open_basedir with suPHP globally and for Per User Basis on CWP – Centos WebPanel
Footer Logo

Copyright - Mystery Data