Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

I'm trying to set the password of the user root but I'm gettin the error below, any idea?

+----------------------------------------------------------------------------------------------------------------------------------------+ | Grants for root@localhost                                                                                                              | +----------------------------------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*436576511F70A4E3B305E1AB8E209851945D8687' WITH GRANT OPTION | +----------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)   mysql> exit Bye root@tirengarfio:/var/www/rs2# mysqladmin -u root password foo, mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)' 
like image 211
ziiweb Avatar asked Dec 16 '11 17:12

ziiweb


People also ask

How do I fix access denied for localhost using password no?

Use the ALTER USER command and change the authentication method to log into MySQL as root: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password'; This command changes the password for the user root and sets the authentication method to mysql_native_password.

How do I fix root access denied?

Solution 1: Sudo then Change Password If you get the “access denied” error, one way to solve it is by using sudo to log in to mysql and change the root password. Step 1: Open the command line on your system. Step 3: Enter the password for this account.

How do I fix MySQL Access Denied?

To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password'; Replace user_name with the user's username and password with the user's password.


2 Answers

$ mysqladmin -u root -p password Enter password:  New password:  Confirm new password: 

password is to be typed literally. It's a command. You don't have to substitute password with your actual password.

like image 185
djrconcepts Avatar answered Sep 22 '22 16:09

djrconcepts


# /etc/init.d/mysqld stop  Stopping MySQL: [ OK ]  # mysqld_safe --skip-grant-tables &  [1] 13694  # Starting mysqld daemon with databases from /var/lib/mysql    # mysql -u root  Welcome to the MySQL monitor. Commands end with ; or \g.  Your MySQL connection id is 1  Server version: 5.0.77 Source distribution    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.    mysql> 
like image 32
Hamsavardhini Deventhiran Avatar answered Sep 22 '22 16:09

Hamsavardhini Deventhiran