Monday, August 17, 2015

How to reset your first installed mysql database password?

  • For newly installed mysql database, the default database password is empty
  • In order to reset the password, type in the "mysql" command at terminal window. 
  • Type in the command below to reset the password
mysql > UPDATE mysql.user SET password=password('password') WHERE user='root' AND host='localhost';
  • If the error message as shown below is displayed
ERROR 1227 (42000): Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
  • Add the 2 parameter to my.cnf file
[mysqld]
skip-grant-tables
skip-networking
  • Restart mysql services
  • Type in command "mysql" to login into mysql, rerun the command below, you should be able to reset your root password
mysql > UPDATE mysql.user SET password=password('password') WHERE user='root' AND host='localhost';
mysql > FLUSH PRIVILEGES; 

No comments: