# Not being able to reset ROOT Password for Mysql !!!!

**URL:** <https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686>\
**Category:** Other MySQL® Questions\
**Created:** [May 16, 2013, 6:35am UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686 "2013-05-16T06:35:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![systemali](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@systemali](https://forums.percona.com/u/systemali)\
**Post date:** [May 16, 2013, 6:35am UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/1 "2013-05-16T06:35:54Z")

</div>

Hello every one !!

I am trying to start mysql in safe mode to reset my root password, and i get this error below :-

I first stop it :-

root@DatabackupSRV ~/home # /etc/init.d/mysql stop  
Shutting down MySQL. [OK]

Then try to start in safe mode :-

root@DatabackupSRV /var/lib/mysql # mysqld\_safe --skip-grant-tables &  
[1] 24880  
root@DatabackupSRV /var/lib/mysql # 130516 22:57:01 mysqld\_safe Logging to ‘/var/log/mysqld.log’.  
130516 22:57:01 mysqld\_safe Starting mysqld daemon with databases from /var/lib/mysql  
130516 22:57:03 mysqld\_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

I check the /var/log/messages and this is what is see :-

root@DatabackupSRV /var/lib/mysql # tail -f /var/log/messages  
May 16 20:53:19 DatabackupSRV smbd[10900]: [2013/05/16 20:53:19, 0] lib/util\_sock.c:write\_data(568)  
May 16 20:53:19 DatabackupSRV smbd[10900]: write\_data: write failure in writing to client 10.222.37.17. Error Broken pipe  
May 16 20:53:19 DatabackupSRV smbd[10900]: [2013/05/16 20:53:19, 0] lib/util\_sock.c:send\_smb(767)  
May 16 20:53:19 DatabackupSRV smbd[10900]: Error writing 75 bytes to client. -1. (Broken pipe)  
May 16 21:44:34 DatabackupSRV yum: Installed: Percona-SQL-shared-50-5.0.92-b23.89.rhel5.x86\_64  
May 16 21:44:35 DatabackupSRV yum: Installed: perl-DBD-MySQL-3.0007-2.el5.x86\_64  
May 16 21:52:25 DatabackupSRV smbd[12713]: [2013/05/16 21:52:25, 0] lib/util\_sock.c:read\_data(540)  
May 16 21:52:25 DatabackupSRV smbd[12713]: read\_data: read failure for 4 bytes to client 10.222.37.18. Error = Connection timed out  
May 16 21:56:39 DatabackupSRV smbd[24143]: [2013/05/16 21:56:39, 0] lib/util\_sock.c:read\_data(540)  
May 16 21:56:39 DatabackupSRV smbd[24143]: read\_data: read failure for 4 bytes to client 10.222.11.25. Error = Connection reset by peer

Can any one point out what am i missing ? OR what wrong am i doing ☹

Thank you !!

---

<div class="post-metadata">

**Author:** ![scott.nemes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/scott.nemes/32/5_2.png) [@scott.nemes](https://forums.percona.com/u/scott.nemes)\
**Post date:** [May 16, 2013, 10:05am UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/2 "2013-05-16T10:05:34Z")

</div>

Try the below guide, section C.5.4.1.2. Resetting the Root Password: Unix Systems

[url][http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html[/url]](http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html%5B/url%5D)

---

<div class="post-metadata">

**Author:** ![systemali](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@systemali](https://forums.percona.com/u/systemali)\
**Post date:** [May 16, 2013, 11:41am UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/3 "2013-05-16T11:41:25Z")

</div>

Hello Scott,

I have followed that link earlier today, But could not reset it, every time i restart mysql in the safe mode, the PID of mysql in safe mode dies away !!!

Any other thing that could be going wrong ? or i am missing ?

Thank you

---

<div class="post-metadata">

**Author:** ![scott.nemes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/scott.nemes/32/5_2.png) [@scott.nemes](https://forums.percona.com/u/scott.nemes)\
**Post date:** [May 16, 2013, 12:17pm UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/4 "2013-05-16T12:17:14Z")

</div>

Try placing the init file SQL script in your MySQL data directory, and make sure it is owned by mysql and give it a chmod of 700.

Then run the below, but change the path to match your data dir and whatever file name you used:  
mysqld\_safe --init-file=/datadir/mysql-init &

Once the server starts up, attempt to login as root using whatever password you set in the init script.

If that does not work, post your error log contents here so we can take a look at that. =)

---

<div class="post-metadata">

**Author:** ![systemali](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@systemali](https://forums.percona.com/u/systemali)\
**Post date:** [May 16, 2013, 10:03pm UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/5 "2013-05-16T22:03:55Z")

</div>

Scott,

Pardon my ignorance, can yo be more precise as to where is this file present ( init file ) on the server ?

Is it the file that is in this location :- /etc/init.d/mysqld or something else that i am not getting to ☹

Please suggest !!

Thank you

---

<div class="post-metadata">

**Author:** ![systemali](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@systemali](https://forums.percona.com/u/systemali)\
**Post date:** [May 16, 2013, 11:31pm UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/6 "2013-05-16T23:31:28Z")

</div>

Hello Scott,

Assuming that i need to copy the file from /etc/init.d/mysql to my data directory :-

This is what i did, [ALL THIS IS AT MY SLAVE or REPLICATION SERVER]

My datadir is at :- /var/lib/mysql

a) copied mysql file from /etc/init.d/mysql to /var/lib/mysql/

NOTE :- there was a directory by the name of mysql at data directory location, i had to rename it to copy the file here.

b) I then, chmod 700 mysql & chown mysql:mysql mysql

c) started mysql :- mysqld\_safe --init-file=/var/lib/mysql/mysql &

This is the error i got on the screen :-

root@DatabackupSRV /var/lib/mysql # mysqld\_safe --init-file=/var/lib/mysql/mysql &  
[1] 24911  
root@DatabackupSRV /var/lib/mysql # 130517 15:50:59 mysqld\_safe Logging to ‘/var/log/mysqld.log’.  
130517 15:50:59 mysqld\_safe Starting mysqld daemon with databases from /var/lib/mysql  
130517 15:51:01 mysqld\_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

When i tail the logs i get this error :-

root@DatabackupSRV /var/lib/mysql # tail -f /var/log/messages  
May 16 23:23:48 DatabackupSRV smbd[25411]: [2013/05/16 23:23:48, 0] lib/util\_sock.c:read\_data(540)  
May 16 23:23:48 DatabackupSRV smbd[25411]: read\_data: read failure for 4 bytes to client 10.222.37.17. Error = Connection timed out  
May 16 23:23:48 DatabackupSRV smbd[25411]: [2013/05/16 23:23:48, 0] lib/util\_sock.c:write\_data(568)  
May 16 23:23:48 DatabackupSRV smbd[25411]: write\_data: write failure in writing to client 10.222.37.17. Error Broken pipe  
May 16 23:23:48 DatabackupSRV smbd[25411]: [2013/05/16 23:23:48, 0] lib/util\_sock.c:send\_smb(767)  
May 16 23:23:48 DatabackupSRV smbd[25411]: Error writing 75 bytes to client. -1. (Broken pipe)  
May 17 00:01:41 DatabackupSRV smbd[25414]: [2013/05/17 00:01:41, 0] lib/util\_sock.c:read\_data(540)  
May 17 00:01:41 DatabackupSRV smbd[25414]: read\_data: read failure for 4 bytes to client 10.222.37.18. Error = Connection reset by peer  
May 17 00:12:52 DatabackupSRV smbd[5908]: [2013/05/17 00:12:52, 0] lib/util\_sock.c:read\_data(540)  
May 17 00:12:52 DatabackupSRV smbd[5908]: read\_data: read failure for 4 bytes to client 10.222.11.22. Error = No route to host

Please let me know where am i wrong here ☹

Thank you for your time as always !!

---

<div class="post-metadata">

**Author:** ![systemali](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@systemali](https://forums.percona.com/u/systemali)\
**Post date:** [May 17, 2013, 1:30am UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/7 "2013-05-17T01:30:09Z")

</div>

Scott,

Pheww…finally i managed to change the password 😃

What i did was, :-

a) moved the /etc/my.cnf to /etc/my.cnf\_bak  
b) created an empty my.cnf  
c) and then stopped mysql and restarted it like this :-mysqld\_safe --skip-grant-tables &  
d) Issued these commands in turn :-

USE mysql;  
UPDATE user SET password=PASSWORD(“NEW-ROOT-PASSWORD”) WHERE User=‘root’;  
FLUSH privileges;  
quit

e) moved back the old my.cnf\_bak to my.cnf  
f ) started mysql again normally :- /etc/init.d/mysql restart  
g ) tried to enter again into mysql normally :- mysql -uroot -p

Horryyy yyy!!!

May help some one some time 😃

---

<div class="post-metadata">

**Author:** ![scott.nemes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/scott.nemes/32/5_2.png) [@scott.nemes](https://forums.percona.com/u/scott.nemes)\
**Post date:** [May 17, 2013, 12:38pm UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/8 "2013-05-17T12:38:44Z")

</div>

Glad you got it fixed. In your previous attempt, you were trying to pass MySQL the init.d script (/etc/init.d/mysql), which would not work. That script is used to start and stop MySQL. You were needing to create a separate SQL script and pass it to MySQL with the --init-file option. But you ended up doing mainly the same thing in a different way, so that’s the important part. =)

---

<div class="post-metadata">

**Author:** ![systemali](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@systemali](https://forums.percona.com/u/systemali)\
**Post date:** [May 18, 2013, 1:00am UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/9 "2013-05-18T01:00:18Z")

</div>

Ohh oke,

Scott, I really really appreciate all your assistance 🙂 this regards,

Yes, at the end resolution is what matter 🙂

Take care

---

<div class="post-metadata">

**Author:** ![kyakruu](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kyakruu](https://forums.percona.com/u/kyakruu)\
**Post date:** [February 9, 2016, 2:14am UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/10 "2016-02-09T02:14:59Z")

</div>

===

---

<div class="post-metadata">

**Author:** ![Jamie](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@Jamie](https://forums.percona.com/u/Jamie)\
**Post date:** [February 11, 2016, 1:46am UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/11 "2016-02-11T01:46:21Z")

</div>

Visit this link on how to reset root password - [url][http://tekslate.com/user-account-management-mysql/[/url]](http://tekslate.com/user-account-management-mysql/%5B/url%5D)

---

<div class="post-metadata">

**Author:** ![rwigfall](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@rwigfall](https://forums.percona.com/u/rwigfall)\
**Post date:** [October 2, 2018, 12:25pm UTC](https://forums.percona.com/t/not-being-able-to-reset-root-password-for-mysql/2686/12 "2018-10-02T12:25:59Z")

</div>

I ran into this problem and thought I would add some info.

There seems to be two approaches here:  
1.) Bakup the current my.cnf, create an empty my.cnf, and start mysql in safe mode mysqld\_safe -skip-grant-tables  
2.) Use the mysqld --init-file=/home/me/mysql-init approach

I chose approach one.  
I stopped only one PXC node.

The instructions all worked fine until I went to update the password. The password field is now called ‘authentication\_string’ I am sure the field names changed after some version, not sure what version.  
if UPDATE user SET password=PASSWORD(‘new-root-pass’) WHERE user = ‘root’; does not work for you try  
UPDATE user SET authentication\_string=PASSWORD(‘new-root-pass’) WHERE user = ‘root’;
