3

I have tried various options I got from Google but unable to set password for root. I can login without any password, but the Java drivers require a password, so I have to set it.

In my last attempt, I tried following command in the MySQL console:

SET PASSWORD FOR root@localhost=PASSWORD('abc123');

But I got following error:

ERROR 1133 <42000>: Can't find any matching row in the user table
2
  • 1
    what user are you logged in as? root? Commented May 19, 2014 at 13:55
  • yes i am logged in as root but with no password. 1 more thing i forgot i have installed wamp Commented May 19, 2014 at 13:59

3 Answers 3

2

Enter the following lines in your terminal.

Stop the MySQL Server.

sudo /etc/init.d/mysql stop

Start the mysqld configuration. (in safe mode)

sudo mysqld_safe --skip-grant-tables & 

Login to MySQL as root.

mysql -u root mysql

Replace YOURNEWPASSWORD with your new password!

UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; 
FLUSH PRIVILEGES; 
exit;

sudo /etc/init.d/mysql start

REFERENCES :

http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password https://help.ubuntu.com/community/MysqlPasswordReset

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Updating the mysql.user table directly worked for me, while SET PASSWORD FOR.. failed not being able to find a matching row.
0

It could be that the user root for localhost does not exists. Adding this account can be done by:

CREATE USER 'root'@'localhost' IDENTIFIED BY 'abc123';

1 Comment

thanks, but this command resulted in another error ACCESS DENIED: You need (at least one of) the CREATE USER privileges for this operation.
0

In MySQL, each user is uniquely identified by both the username and the host, meaning that root@localhost is not the same user as [email protected] or root@% (for example). It could be that you don't have the root@localhost user that you're trying to set the password for.

Double-check which users you actually have in the mysql.user table:

SELECT * FROM mysql.user WHERE user = 'root';

If you want create the missing user, use these statements instead:

CREATE USER root@localhost IDENTIFIED BY 'abc123';
GRANT ALL PRIVILEGES ON *.* TO root@localhost;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.