Discover Centmin Mod today
Register Now

Recovering a lost mysql root password

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Matt Williams, Jan 26, 2015.

  1. Matt Williams

    Matt Williams WordPress Fanatic

    468
    90
    28
    Nov 22, 2014
    Virginia, USA
    Ratings:
    +135
    Local Time:
    9:37 PM
    latest
    10
    I'm digging through install logs and I can't seem to find this no where. Is their an easier way to find this?
     
  2. mgaidia

    mgaidia New Member

    23
    11
    3
    Dec 4, 2014
    Austria
    Ratings:
    +12
    Local Time:
    3:37 AM
    1.7.9
    5.5.41
    you can always start mysql in safemode (equivalent of single user mode in linux) and reset the root password.
     
  3. Matt Williams

    Matt Williams WordPress Fanatic

    468
    90
    28
    Nov 22, 2014
    Virginia, USA
    Ratings:
    +135
    Local Time:
    9:37 PM
    latest
    10
    How exactly would I do that? - Thank you for your response mgaidia!
     
  4. mgaidia

    mgaidia New Member

    23
    11
    3
    Dec 4, 2014
    Austria
    Ratings:
    +12
    Local Time:
    3:37 AM
    1.7.9
    5.5.41
    What operating system are you using ?
     
  5. Matt Williams

    Matt Williams WordPress Fanatic

    468
    90
    28
    Nov 22, 2014
    Virginia, USA
    Ratings:
    +135
    Local Time:
    9:37 PM
    latest
    10
    centOS 6
     
  6. mgaidia

    mgaidia New Member

    23
    11
    3
    Dec 4, 2014
    Austria
    Ratings:
    +12
    Local Time:
    3:37 AM
    1.7.9
    5.5.41
    Execute the following in order:
    Code:
    sudo /etc/init.d/mysqld stop
    sudo mysqld_safe --skip-grant-tables &
    mysql -u root
    use mysql;
    update user set password=PASSWORD("PUT_A_NEW_PASSWD_HERE") where User='root';
    flush privileges;
    quit or ctrl+D or exit
    sudo /etc/init.d/mysqld stop
    sudo /etc/init.d/mysqld start
    
     
    Last edited by a moderator: Mar 27, 2016
  7. Matt Williams

    Matt Williams WordPress Fanatic

    468
    90
    28
    Nov 22, 2014
    Virginia, USA
    Ratings:
    +135
    Local Time:
    9:37 PM
    latest
    10
    Thank you! Worked like a charm. However, I had to use the short codes mysqlstop/start but other then that, worked perfect! Thanks again!​
     
  8. mgaidia

    mgaidia New Member

    23
    11
    3
    Dec 4, 2014
    Austria
    Ratings:
    +12
    Local Time:
    3:37 AM
    1.7.9
    5.5.41
    I used /etc/init.d/mysqld because it uses the absolute path which should work on all systems. I always try to avoid aliases when giving instruction to a third party.
    You are most welcome by the way.
     
  9. eva2000

    eva2000 Administrator Staff Member

    45,199
    10,277
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,928
    Local Time:
    11:37 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x