LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-03-2014, 01:45 AM   #1
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Rep: Reputation: Disabled
forgot mysql password


In my server , the mysql ID is created by the command "mysql" , I forogt some mysql ID ( not root user ) password , would advise how to get back the password ( not reset it ) ? thanks

Last edited by byran cheung; 12-03-2014 at 02:12 AM.
 
Old 12-03-2014, 02:11 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,880
Blog Entries: 1

Rep: Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998
I am not certain of your meaning, but it is probably one of these:

1. The system user "mysql" login password - normally the mysql user will not have a login shell or password, it exists only to run the mysql server and to own the database directory tree. If you had set a password for this user you cannot recover it, but the root user can reset it.

2. The system mysql user mysql server password - again, the mysql user normally does not have a mysql server password. If you had set one with a GRANT statement, another user with GRANT privs may be able to reset it, but not recover it.

3. If you mean a normal user's mysql server password - Again, not recoverable, but can be reset by another user with GRANT privs.

In all cases the passwords are stored only as non-reversible hashes, so a user with adequate permission can change the passwords but not recover them.

For shell passwords, the root user may do this with the passwd command (see man page).

For mysql accounts, you may use a REVOKE/GRANT statement to set a new GRANT, including new password, or you can directly update the mysql.user table similar to this:

Code:
mysql> UPDATE mysql.user SET Password=PASSWORD('NewPassWord') WHERE User='username';
UPDATE: As you have updated the question while I was typing, to exclude resetting but only recover it, I will update my answer here as well...

As far as I know, you cannot recover them (i.e. reverse the hash). They are stored as one-way hashes so you can only reset, not recover.

Last edited by astrogeek; 12-03-2014 at 02:19 AM.
 
Old 12-03-2014, 04:45 AM   #3
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by astrogeek View Post
I am not certain of your meaning, but it is probably one of these:

1. The system user "mysql" login password - normally the mysql user will not have a login shell or password, it exists only to run the mysql server and to own the database directory tree. If you had set a password for this user you cannot recover it, but the root user can reset it.

2. The system mysql user mysql server password - again, the mysql user normally does not have a mysql server password. If you had set one with a GRANT statement, another user with GRANT privs may be able to reset it, but not recover it.

3. If you mean a normal user's mysql server password - Again, not recoverable, but can be reset by another user with GRANT privs.

In all cases the passwords are stored only as non-reversible hashes, so a user with adequate permission can change the passwords but not recover them.

For shell passwords, the root user may do this with the passwd command (see man page).

For mysql accounts, you may use a REVOKE/GRANT statement to set a new GRANT, including new password, or you can directly update the mysql.user table similar to this:

Code:
mysql> UPDATE mysql.user SET Password=PASSWORD('NewPassWord') WHERE User='username';
UPDATE: As you have updated the question while I was typing, to exclude resetting but only recover it, I will update my answer here as well...

As far as I know, you cannot recover them (i.e. reverse the hash). They are stored as one-way hashes so you can only reset, not recover.
thanks reply ,

What I mean is I use the command "mysql" to create 3 mysql ID , but I forgot the password of these 3 mysql ID ( not system ID , just general mysql ID ) , except reset the password , how can I get back the password ? thanks
 
Old 12-03-2014, 09:55 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,880
Blog Entries: 1

Rep: Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998
Quote:
Originally Posted by byran cheung View Post
thanks reply ,

What I mean is I use the command "mysql" to create 3 mysql ID , but I forgot the password of these 3 mysql ID ( not system ID , just general mysql ID ) , except reset the password , how can I get back the password ? thanks
That is case 3. above...

As I said, unless you wrote them down somewhere, you cannot get them back from the system.

Last edited by astrogeek; 12-03-2014 at 10:07 AM.
 
Old 12-03-2014, 12:04 PM   #5
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,493

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635
Passwords are stored as a hash and cannot be recovered.

However, mysql uses a command line history (like Bash). Maybe it is not too long ago you created those users and the commands are still in the command line history.

jlinkels
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
forgot my password acshivers828 Linux - Newbie 2 11-22-2010 06:49 PM
How to retrieve( or reset) root password in Mandrake Linux, as I forgot my password? Reghunath Linux - Software 4 05-08-2008 05:11 AM
Forgot PASSWORD !!! bipinkdas Ubuntu 2 03-27-2005 11:37 AM
forgot password =( ?!?! j_miguel_y Linux - General 1 08-31-2004 12:58 PM
forgot my password ? i can change the password JrLz Linux - Security 9 04-06-2004 08:36 PM


All times are GMT -5. The time now is 12:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration