We all have worked in Mysql with the default username ‘root’ and password ‘root’ but we should not keep our Mysql password to default as its insecure. I am here with a blog which helps you change the password of Mysql with minimal steps and various ways.

 

For Mysql, the system administrator user is called root. You will use the mysqladmin utility from a Terminal to set the new password or by logging into the Mysql shell as under : –

  1. Stop your running server.
    sudo /etc/init.d/mysql stop
  2. Use command if mysqladmin util exists ( this is a insecure as you set a password from command line which can be viewed by others in case of public computer avoid this and user the next command below.)
    mysqladmin -u root -p password NEW_PASSWORD

    or
    login into the mysql shell –

    mysql -u root -p

    and then

    UPDATE user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;

  3. Start the server.
    sudo /etc/init.d/mysql start

 

And you are done.

 

Enjoy coding.