LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-09-2013, 02:45 PM   #1
saeeds255
LQ Newbie
 
Registered: Nov 2013
Posts: 5

Rep: Reputation: Disabled
I forget the mysql password and cant change it


Hello,

I just set a password for mysql in Ubuntu webmin and when i enter that it returns error.

I try some methods but one of them was better.
I try this codes:

1. /etc/init.d/mysql stop (done without error)
2. mysqld_safe --skip-grant-tables & (done without error)
3. mysql -u root (connect to mysql)
4. use mysql;
update user set password=PASSWORD(“PASSWORD”)
where User=’root’;
flush privileges;
quit;

also step 4 done completely and i receive these massages :
"Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

Query OK, 0 rows affected (0.00 sec)

Bye"

finally I reset mysql with these two commands :
/etc/init.d/mysql stop
/etc/init.d/mysql start

but when i use the command "mysql -u root -p" to enter the passwort it says : "access denied for user root at localhost (using password: yes)"

why I cant enter now ? does anyone have solution or another method for this?
 
Old 11-09-2013, 03:17 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,614

Rep: Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962
Quote:
Originally Posted by saeeds255 View Post
Hello,
I just set a password for mysql in Ubuntu webmin and when i enter that it returns error.

I try some methods but one of them was better. I try this codes:

1. /etc/init.d/mysql stop (done without error)
2. mysqld_safe --skip-grant-tables & (done without error)
3. mysql -u root (connect to mysql)
4. use mysql;
update user set password=PASSWORD(“PASSWORD”)
where User=’root’;
flush privileges;
quit;

also step 4 done completely and i receive these massages :
"Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
Query OK, 0 rows affected (0.00 sec)
Bye"

finally I reset mysql with these two commands :
/etc/init.d/mysql stop
/etc/init.d/mysql start

but when i use the command "mysql -u root -p" to enter the passwort it says : "access denied for user root at localhost (using password: yes)"
why I cant enter now ? does anyone have solution or another method for this?
You need to get a root shell (either "sudo -s" or "su - root"), then just type in "mysql".
 
Old 11-10-2013, 03:19 AM   #3
saeeds255
LQ Newbie
 
Registered: Nov 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
You need to get a root shell (either "sudo -s" or "su - root"), then just type in "mysql".
can you exactly say in witch step should I get a root shell ?
can i get root shell for mysql just with the "sudo -s" command ?

I just use this command for setting password : password=PASSWORD("");
then : select user , password , host from user;
and I saw that the password of all users is blank but when i want to enter mysql (after restarting mysql) i get this error :

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

why I cant login when I dont set any password ?

please help me, thanks a lot ...

Last edited by saeeds255; 11-10-2013 at 09:03 AM.
 
Old 11-10-2013, 11:11 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,614

Rep: Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962
Quote:
Originally Posted by saeeds255 View Post
can you exactly say in witch step should I get a root shell ?
can i get root shell for mysql just with the "sudo -s" command ?
Yes, that's why I said to Do exactly that before.
Quote:

I just use this command for setting password : password=PASSWORD("");
then : select user , password , host from user;
and I saw that the password of all users is blank but when i want to enter mysql (after restarting mysql) i get this error :

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

why I cant login when I dont set any password ?

please help me, thanks a lot ...
Re-read the first post. Do What it says
 
Old 11-10-2013, 02:28 PM   #5
saeeds255
LQ Newbie
 
Registered: Nov 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Yes, that's why I said to Do exactly that before.

Re-read the first post. Do What it says
you know, my problem is just that I cant enter to a mysql that hasnt any password. in spite of it hasnt password but asks me to enter the password !!

how can I completely remove mysql with all of its data then install it again ?
I removed and reinstall it through wembin but the password didnt change.
 
1 members found this post helpful.
Old 11-10-2013, 03:14 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,614

Rep: Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962
Quote:
Originally Posted by saeeds255 View Post
you know, my problem is just that I cant enter to a mysql that hasnt any password. in spite of it hasnt password but asks me to enter the password !!

how can I completely remove mysql with all of its data then install it again ?
I removed and reinstall it through wembin but the password didnt change.
Again:

Type in "sudo -s"
Type in "mysql "

That's it. After that, Do What you'd like.
 
Old 11-10-2013, 03:30 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
did you state you uninstalled mysql then reinstalled mysql

as i recall the defaults are
user = USER
password = PASSWORD

that is why it is very important to set them
 
Old 11-10-2013, 03:56 PM   #8
munkz
Member
 
Registered: Aug 2013
Location: A couch
Distribution: linux
Posts: 69

Rep: Reputation: 2
I think your syntax may be a lil off.

1.Reload mysql with dropped privileges.

2. type "use mysq;"

3. Run the following :
Code:
FLUSH PRIVILEGES;
SELECT Host,User,Password FROM user WHERE User='root';   #<<<this is so you can compare and see what you have a root before the change. 
+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *HUNK OF HASH SHOWS HERE VERSION 1        |
| 127.0.0.1 | root | *HUNK OF HASH SHOWS HERE VERSION 1        |
+-----------+------+-------------------------------------------+


SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');     #<<<not sure but I think you need to define where root will be connecting from with the ip. 
SELECT Host,User,Password FROM user WHERE User='root';   #<<<again, compare the fields to see if your SET/UPDATE took.
+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *HUNK OF HASH SHOWS HERE VERSION 2        |
| 127.0.0.1 | root | *HUNK OF HASH SHOWS HERE VERSION 2        |
+-----------+------+-------------------------------------------+
FLUSH PRIVILEGES;
exit
Now, reload MySQL as normal and try it out. If that does not work, I think home depo has a sale on hammers this weekend.
 
Old 11-11-2013, 01:57 AM   #9
saeeds255
LQ Newbie
 
Registered: Nov 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
thanks my friends, I finally made it. I think its a good experience for everyone
so I want to share it :

1. ( sudo -s), then (mysql) doesn't work !

2. ( mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set password=PASSWORD(“PASSWORD”) where User=’root’;
flush privileges;
quit; ) it just change the root and other users passwords.

3. this way I could solve it :
( mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password';
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password'); ~~> I think this part is not needed but i use it.
flush privileges; ~~> this part is not needed i just add it for fun
quit

Last edited by saeeds255; 11-11-2013 at 01:58 AM.
 
  


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
[SOLVED] change root password error in mysql jitendra.sharma Linux - Server 3 03-12-2013 08:59 AM
change mysql username and password on ec2 lamp ggalan Linux - Newbie 4 04-04-2012 07:43 PM
How can i change mysql password in ubuntu 10.04 jayakumar01 Linux - Server 4 01-04-2012 10:27 AM
How can I change the root password of MYSQL server Muideen Linux - Newbie 5 03-19-2009 06:49 PM
[MySQL] forget password :/ what to do? hunter_one Linux - Software 1 04-12-2004 06:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:45 AM.

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