Clutch

HOW TO: Resetting MySQL root password for the Greater Good!

HOW TO: Resetting MySQL root password for the Greater Good!
Average rating: 0
(0 votes)

HOW TO: Resetting MySQL root password for the Greater Good!

  1. The perfect day for simple task: resetting MySQL root password in production database.
  2. Got to http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html . And it can help, but –init-file version somehow flawed. We can do better!
  3. Open terminal and ssh to production server
  4. Ensure MySQL is running
      ps aux | grep mysql 
    Must be at least one mysqld process. Ensure it’s not zombie, but daemon.
  5. Stop mysql daemonsudo stop mysql (Your server is ubuntu, right? )
  1. Start mysql without privilegessudo mysqld_safe –skip-grant-tables &Ampersand on the end is very important. Don’t forget it.
  2. Open new terminal and ssh to your production server once more
  3. Login to mysql dbmysql -u root
  4. Inside mysql> prompt:
    use mysql;
    update user set password=PASSWORD(“mynewpassword”) where User=’root’;
    flush privileges;
    quit
  5. In your previous terminal window tap enter
  6. Start fresh MySQL daemonsudo start mysql
  7. Now you could login to MySQL database with your super new root passwordmysql -u root -p

 

Based heavily on https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/ and tested with MySQL version 5.5.35 on Ubuntu 13.04. 

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

*By submitting this form you agree with our Privacy Policy.

Mailing & Legal Address

Syndicode Inc. 340 S Lemon Ave #3299, Walnut CA, 91789, USA

Visiting & Headquarters address
Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
Email info@syndicode.com
Phone (+1) 9035021111