Solved

How to reset mysql password in CentOS 6.5 ?

Posted on 2014-09-25
10
1,782 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
 
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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now