MySQL Recover/Reset Lost/Forgotten root Password

One note is to secure MySQL, I don't know for sure but I believe you could login to MySQL remotely with no password during this operation (I'm not sure, maybe it doesn't accept blank passwords but I firewall MySQL port anyway and recommend you do the same).

First edit /etc/my.cf

Under the [mysqld] field add the following line somewhere:

skip-grant-tables

Now restart mysql: service mysql restart or on Debian style systems: /etc/init.d/mysqld restart

You can now login to mysql as root with no password.

mysql -u root

Enter the following commands (you can copy and paste below, remember to change "YOURNEWPASSWORD" to whatever you want the password to be.

use mysql;
UPDATE user SET password=password("YOURNEWPASSWORD") WHERE user='root';
flush privileges;
quit

*Note more note is that if you are using Plesk, the root user is probably called/renamed "admin" so you'll need to replace everything above with "admin" if that's the case.  Of course an easier way if Plesk is actually running is to use the Forgot Password function of the Control Panel itself.


Tags:

mysql, reset, passwordone, login, remotely, password, doesn, passwords, firewall, edit, etc, cf, mysqld, restart, debian, init, commands, quot, yournewpassword, update, user, flush, privileges, plesk, renamed, admin, ll, panel,

Latest Articles

  • Linux Ubuntu Cannot Print Large Images
  • Cannot Print PDF Solution and Howto Resize
  • Linux Console Login Screen TTY Change Message
  • Apache Cannot Start Listening Already on 0.0.0.0
  • MySQL Bash Query to pipe input directly without using heredoc trick
  • CentOS 6 and 7 / RHEL Persistent DHCP Solution
  • Debian Ubuntu Mint rc-local service startup error solution rc-local.service: Failed at step EXEC spawning /etc/rc.local: Exec format error
  • MySQL Cheatsheet Guide and Tutorial
  • bash script kill whois or other command that is running for too long
  • Linux tftp listens on all interfaces and IPs by DEFAULT Security Risk Hole Solution
  • python import docx error
  • Cisco Unified Communications Manager Express Cheatsheet CUCME CME
  • Linux Ubuntu Debian Missing privilege separation directory: /var/run/sshd
  • bash how to count the number of columns or words in a line
  • bash if statement how to test program output without assigning to variable
  • RTNETLINK answers: Network is unreachable
  • Centos 7 how to save iptables rules like Centos 6
  • nfs tuning maximum amount of connections
  • qemu-kvm error "Could not initialize SDL(No available video device) - exiting"
  • Centos 7 tftpd will not work with selinux enabled