Wednesday, August 25, 2010

error: 'Access denied for user 'root'@'localhost' (using password: NO)'

error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Some of us come ac crossed this error when we try connecting Mysql  using no password. ie., when we connect  the mysql by the command "mysql -u root" . When we installing mysql in windows it will ask root password for creating my.ini file. After configuring root password when ever you connect the mysql you should use the command "mysql -u root -p" and enter the password when prompted.  


This will create head aches when you connect mysql through java driver using connection string with out password in a development environment.  To over come this, just reset the password to empty string by using the following three steps/commands - 

  1. UPDATE mysql.user SET Password=PASSWORD('') WHERE User='root';
  2. grant all privileges on *.* to root;
  3. FLUSH PRIVILEGES;

No comments:

Post a Comment