• Lost MySQL Root Password

    I work on so many sites, domains, linux boxes, MySQL servers, etc. that I have like a million and one passwords dancing around in my head. Went to add a database to an old devel box that I haven’t used for about 2 years and I couldn’t remember the MySQL root password. So I had to reset it. If anyone finds themselves in this situation, here’s how you do it if you have root access to the server. I’ll use my normal way of stopping/starting the service, you may need to alter this for your server.

    /etc/init.d/mysql stop
    mysqld --skip-grant-tables &
    mysql (to get to MySQL shell)
    mysql> update user set password = ('newpasssword') where user='root';
    mysql> flush privileges;
    mysql> exit;
    /etc/init.d/mysql restart
    
    • Share/Bookmark

     Leave a reply