LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-30-2004, 04:05 AM   #1
andredude
Member
 
Registered: Dec 2003
Location: Johannesburg, South Africa
Distribution: Mandrake
Posts: 48

Rep: Reputation: 15
mysql: still can't login after root password reset


please help - I've managed to forget my root password and could not log into mysql. I then:

1. stopped mysqld, and restarted with --skip-grant-tables.
2. changed the root password by updating mysql.user
3. flushed privileges
4. restarted mysqld

when trying to start with 'mysql -u root mysql' i get logged in but whenever I try to do something I get

ERROR 1044: Access denied for user: '@localhost' to database 'mysql'

when trying to start with 'mysql -p -u root mysql' so i get prompted for my password and i type it in, i get:

ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)

please help this thing is driving me up the wall. as you've probably seen above i'm no mysql expert.

thanks

andre
 
Old 05-06-2004, 02:43 AM   #2
andredude
Member
 
Registered: Dec 2003
Location: Johannesburg, South Africa
Distribution: Mandrake
Posts: 48

Original Poster
Rep: Reputation: 15
ok, after several hair-pulling-out-in-frustration days i've managed to crack this one so here's the answer IF anybody happens to be interested. The insert to change your password must be in the format:

update mysql.user set password=PASSWORD('password') where user='root';

note the password() function. i'm amazed nobody could help me on this one, on all the forums where i looked the function was not used so the password is inserted in plain text.
 
Old 12-27-2012, 05:10 PM   #3
Den.
LQ Newbie
 
Registered: Dec 2012
Posts: 1

Rep: Reputation: Disabled
Thank you!

Almost 9 years later, I created a new account on this forum just to thank you for the time you took to write the solution to my problem! I spent around 5-6 hours trying to figure this out reading dozens of articles and documentation and thanks to you I was able to solve this problem (which took many production servers down).

And yes, if you get the error "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)" you need to:

1. Stop mysqld, type skip-grant-tables under [mysqld] within the /etc/my.cnf file.
2. Start mysqld
3. login with root mysql -u root -p
4. enter the following command: update mysql.user set password=PASSWORD('password') where user='root';
3. flush privileges
4. restart mysqld
 
Old 12-27-2012, 09:48 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
Also, do not forget to erase the "mysql.log" file after you're done. (You must exit "mysql" command first.) Otherwise the command you just entered will be there along with the password.
 
Old 12-19-2014, 06:30 PM   #5
tushar.bachhav
LQ Newbie
 
Registered: Dec 2014
Posts: 1

Rep: Reputation: Disabled
Smile mysql: still can't login after root password reset

Hi,

@Den

If you add skip-grant-tables under [mysqld] within the /etc/my.cnf file, and do below:

2. Start mysqld
3. login with root mysql -u root -p
4. enter the following command: update mysql.user set password=PASSWORD('password') where user='root';
3. flush privileges
4. restart mysqld

wont fix the issue because it will give an access to any password for root user. Feel free to give it a try.

login with root mysql -u root -p
and type any password and see you will be at mysql prompt which should not happen.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
reset root password kapslock Debian 14 07-27-2006 07:08 AM
MySQL - Canot reset password texmansru47 Linux - Software 1 10-10-2005 05:19 PM
Big problem changed root password for mysql can't login pls comment johnnydangerous Linux - Software 5 07-08-2005 01:22 AM
Need to reset login and password type3 Linux - Newbie 7 12-31-2004 01:45 PM
Reset Root password sdsouza Linux - Software 5 11-12-2003 04:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration