?
Solved

How to reset mysql password in CentOS 6.5 ?

Posted on 2014-09-25
10
Medium Priority
?
2,071 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

765 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