Petro Popelyshko
Petro Popelyshko

Reputation: 1379

Cannot reset mysql password as root

i am using CentOs with mysql 5 version, forgot my password, and i cannot reset it, what i did is

/etc/init.d/mysqld stop

mysqld_safe --skip-grant-tables &
mysql -u root

mysql>  update mysql.user set password=PASSWORD("pass") where User='root';

got this message

Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

mysql> flush privileges; exit;
Query OK, 0 rows affected (0.00 sec)

Stopped and strated mysql but its anyway

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

i have tried this solution mysql official site, not working anyway. Any suggestions?

UPDATE

My main user was admin not root so i changed password for admin all is ok now, sorry for this. thanks everyone.

Upvotes: 1

Views: 4230

Answers (4)

CG_DEV
CG_DEV

Reputation: 818

This worked for me

   UPDATE mysql.user SET Password=PASSWORD('foobar') WHERE User='tom' AND Host='localhost';

This did not work for me

   SET PASSWORD FOR 'user-name-here'@'hostname-name-here' = PASSWORD('new-password-here');

Upvotes: 1

Álvaro González
Álvaro González

Reputation: 146450

Have a closer look at your error message:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
                                                               ^^^^^^^^^^^^^^^^^^

You might have set a new password, but you are not using it to connect.

Upvotes: 2

exussum
exussum

Reputation: 18550

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

make sure what ever is trying to login is definatly sending a password

Upvotes: 0

s.lenders
s.lenders

Reputation: 1149

Try to flush privalages after resetting the password:

    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    FLUSH PRIVILEGES;

If that doesn't work follow these steps: How to Reset the Root Password

Upvotes: -1

Related Questions