Solved

How to reset mysql password in CentOS 6.5 ?

Posted on 2014-09-25
10
1,936 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

733 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