MySQL : How to set password for first time ?

How to set password for first time ?

  1. After the mysqld service has been started, set your mysql server root password by using following commands:
    /usr/bin/mysqladmin -u root password 'new-password'/usr/bin/mysqladmin -u root -h servername password 'new-password'
  2. Note: Alternatively, you can run the secure installation script packaged with the MySQL installation:
    # /usr/bin/mysql_secure_installation Enter current password for root (enter for none):... Set root password? [Y/n] Y ... Remove anonymous users? [Y/n] Y ... Disallow root login remotely? [Y/n] Y ... Remove test database and access to it? [Y/n] Y ... Reload privilege tables now? [Y/n] Y