Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 01:12 AM.
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.
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
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.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.