Add

Wednesday 5 March 2014

Reset ROOT password in MySQL

Using init file while starting the mysql daemon to reset the password of root user in MySQL
 
Step 1) Prepare the init file at : /home/<<location>>/mysql-init - content as fallows
    
        UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;

NOTE: 
You don't need the old password to reset for new, its like something when you forgot/don't know the root password 
 
Step 2)

    i)if you are starting first time after fresh installation

            ## /etc/init.d/mysqld start --init-file=/home/<<location>>/mysql-init & 
 
    ii)if your myslqd already running,     

         a. Kill or stop mysql daemon
            # /etc/init.d/mysqld stop
                or
            # kill -9 <<PID's of all mysqld process>>
         

         b. Start in safe mode

            # mysqld_safe --init-file=/home/<<location>>/mysql-init &
    

    iii)Stop and restart in normal mode to make effect.

             # /etc/init.d/mysqld stop

             # /etc/init.d/mysqld start           


No comments:

Post a Comment