Solved

How to reset mysql password in CentOS 6.5 ?

Posted on 2014-09-25
10
1,871 Views
Last Modified: 2014-09-26
Dear Experts,
I followed this link to reset mysql password in CentOS  http://www.cyberciti.biz/faq/mysql-reset-lost-root-password/
but the process hangs at the third step where I put this command
 mysqld_safe --init-file=/root/mysql.reset.sql &
Below is the output
[root@Plesk ~]# 140925 11:02:48 mysqld_safe Logging to '/var/log/mysqld.log'.
140925 11:02:48 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140925 11:02:54 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
 I manually put enter command and below is the output after that
[1]+  Done                    mysqld_safe --init-file=/root/mysql.reset.sql

As I remember I never put any password while installing mysql but now I want to login to sql to create read only user.
Please help.
Regards.
0
Comment
Question by:ibu1
  • 5
  • 5
10 Comments
 
LVL 6

Expert Comment

by:xeroxzerox
ID: 40343572
Hi
it's easy.just do below step
Set / change / reset the MySQL root password on  Linux. Enter the following lines in your terminal.

#sudo /etc/init.d/mysqld stop
#sudo mysqld_safe --skip-grant-tables &
Login
#mysql -u root
Note: No password is required at this stage as when we started MySQL we skipped the user privileges table.

use mysql;
update user set password=PASSWORD("mynewpassword") where User='root';
flush privileges;
quit
restart service
#sudo /etc/init.d/mysql start
#mysql -u root -p
You will be prompted for your new password.
0
 
LVL 12

Author Comment

by:ibu1
ID: 40343600
After putting command
sudo mysqld_safe --skip-grant-tables &
Below is the output
[root@ABc ~]# 140925 12:07:49 mysqld_safe Logging to '/var/log/mysqld.log'.
140925 12:07:49 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

There is no prompt to type anything after that.
Thanks for quick reply.
0
 
LVL 6

Expert Comment

by:xeroxzerox
ID: 40343610
that message is to say, we will start MySQL but skip the user privileges table.

now login your mysql with below command
#mysql -u root
(no need password when we started MySQL we skipped the user privileges table)
After you use mysql database with below command
use mysql;
update user set password=PASSWORD("mynewpassword") where User='root';
("mynewpassword" = type your password which you want)
flush privileges;
exit

Restart your mysql service and try to login in your mysql
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 12

Author Comment

by:ibu1
ID: 40343669
Hello,
Could not able to change password
Below are the step followed
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=PASSWORD("password") where User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
0
 
LVL 6

Expert Comment

by:xeroxzerox
ID: 40343672
restart your service and when you login in mysql what error or output you get.
#mysql -u root -p
enter password : password
0
 
LVL 12

Author Comment

by:ibu1
ID: 40343676
I already restarted the mysqld service.
Below is the error
[root@Plesk ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
0
 
LVL 6

Expert Comment

by:xeroxzerox
ID: 40343682
when you login in mysql what error or output you get?
0
 
LVL 12

Author Comment

by:ibu1
ID: 40343687
Below is the error
[root@Plesk ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
0
 
LVL 6

Accepted Solution

by:
xeroxzerox earned 500 total points
ID: 40343697
0
 
LVL 12

Author Comment

by:ibu1
ID: 40345846
The above link is exact but the problem was the sql was setup with admin user and not the root user :)
Xeroxzerox, Thanks for your help.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question