Solved

How to reset mysql password in CentOS 6.5 ?

Posted on 2014-09-25
10
1,900 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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why is my wamp get_include_path() wrong? 2 21
trouble on installing syslog-ng on CentOS 7 7 56
issue with DB import 1 18
if (is_singular not working 5 18
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Fine Tune your automatic Updates for Ubuntu / Debian
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

838 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