Which is the easiest way to reset the mysql root password?
up vote
6
down vote
favorite
In the past there has been sudo /etc/init.d/mysql reset-password
, (1) is manually restarting and setting the password with an sql command again required? (2)
(1) http://www.ubuntugeek.com/reset-the-root-password-on-mysql.html
(2) http://www.howtoforge.com/reset-forgotten-mysql-root-password
password mysql
add a comment |
up vote
6
down vote
favorite
In the past there has been sudo /etc/init.d/mysql reset-password
, (1) is manually restarting and setting the password with an sql command again required? (2)
(1) http://www.ubuntugeek.com/reset-the-root-password-on-mysql.html
(2) http://www.howtoforge.com/reset-forgotten-mysql-root-password
password mysql
2
second link look like the way to go
– Panther
Dec 23 '11 at 5:25
add a comment |
up vote
6
down vote
favorite
up vote
6
down vote
favorite
In the past there has been sudo /etc/init.d/mysql reset-password
, (1) is manually restarting and setting the password with an sql command again required? (2)
(1) http://www.ubuntugeek.com/reset-the-root-password-on-mysql.html
(2) http://www.howtoforge.com/reset-forgotten-mysql-root-password
password mysql
In the past there has been sudo /etc/init.d/mysql reset-password
, (1) is manually restarting and setting the password with an sql command again required? (2)
(1) http://www.ubuntugeek.com/reset-the-root-password-on-mysql.html
(2) http://www.howtoforge.com/reset-forgotten-mysql-root-password
password mysql
password mysql
edited Dec 23 '11 at 4:07
Jorge Castro
35.6k105422617
35.6k105422617
asked Dec 23 '11 at 4:06
WhiteZebra
3112
3112
2
second link look like the way to go
– Panther
Dec 23 '11 at 5:25
add a comment |
2
second link look like the way to go
– Panther
Dec 23 '11 at 5:25
2
2
second link look like the way to go
– Panther
Dec 23 '11 at 5:25
second link look like the way to go
– Panther
Dec 23 '11 at 5:25
add a comment |
6 Answers
6
active
oldest
votes
up vote
5
down vote
There's also an administrative user equivalent to root: debian-sys-maint. You can use this account to reset root's password. You can find its password in /etc/mysql/debian.cnf
add a comment |
up vote
4
down vote
You could create a sql file say /root/mysql.reset.sql
with the content:
UPDATE mysql.user SET Password=PASSWORD('yourpassword') WHERE User='root';
FLUSH PRIVILEGES;
And just call:
mysqld_safe --init-file=/root/mysql.reset.sql
Will be very helpful if you are in a habit of forgetting passwords often.
add a comment |
up vote
1
down vote
sudo dpkg-reconfigure mysql-server-5.5
you can use tab complete after mysql-server-
if you're using a different version of mysql.
add a comment |
up vote
1
down vote
tumbleweed's answer was the only one that helped me. I was dealing with what could possibly have been a corrupted root user and none of the standard methods resolved the issue of not being able to log in as root.
Using the debian-sys-maint user, I was able to finally log into MySQL with escalated privileges and even then resetting the root password did not work.
However, I was able to recreate the root user:
DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY '<newpassword>';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
... and finally all was right with the world again!
I hope that helps a desperate soul out there...
add a comment |
up vote
0
down vote
Stop the MySQL Server.
sudo /etc/init.d/mysql stop
Start the mysqld configuration.
sudo mysqld --skip-grant-tables &
Login to MySQL as root.
mysql -u root mysql
Replace YOURNEWPASSWORD with your new password!
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
add a comment |
up vote
0
down vote
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
sudo mysql -u root
use mysql;
update user set authentication_string=PASSWORD("New_Passwore_Here") where User='root';
flush privileges;
exit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Hello and welcome to AU. Your answer might be correct but should be documented: it is not recommended to just give an instruction list. In this case, I do not see a problem but, in general, if a user mistypes something, it could lead to unwanted results. You also use 'sudo' even when it is not necessary (sudo mysql...
) which is potentially dangerous.
– Marc Vanhoomissen
May 14 at 12:02
add a comment |
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
There's also an administrative user equivalent to root: debian-sys-maint. You can use this account to reset root's password. You can find its password in /etc/mysql/debian.cnf
add a comment |
up vote
5
down vote
There's also an administrative user equivalent to root: debian-sys-maint. You can use this account to reset root's password. You can find its password in /etc/mysql/debian.cnf
add a comment |
up vote
5
down vote
up vote
5
down vote
There's also an administrative user equivalent to root: debian-sys-maint. You can use this account to reset root's password. You can find its password in /etc/mysql/debian.cnf
There's also an administrative user equivalent to root: debian-sys-maint. You can use this account to reset root's password. You can find its password in /etc/mysql/debian.cnf
answered Dec 23 '11 at 6:18
tumbleweed
7,0981734
7,0981734
add a comment |
add a comment |
up vote
4
down vote
You could create a sql file say /root/mysql.reset.sql
with the content:
UPDATE mysql.user SET Password=PASSWORD('yourpassword') WHERE User='root';
FLUSH PRIVILEGES;
And just call:
mysqld_safe --init-file=/root/mysql.reset.sql
Will be very helpful if you are in a habit of forgetting passwords often.
add a comment |
up vote
4
down vote
You could create a sql file say /root/mysql.reset.sql
with the content:
UPDATE mysql.user SET Password=PASSWORD('yourpassword') WHERE User='root';
FLUSH PRIVILEGES;
And just call:
mysqld_safe --init-file=/root/mysql.reset.sql
Will be very helpful if you are in a habit of forgetting passwords often.
add a comment |
up vote
4
down vote
up vote
4
down vote
You could create a sql file say /root/mysql.reset.sql
with the content:
UPDATE mysql.user SET Password=PASSWORD('yourpassword') WHERE User='root';
FLUSH PRIVILEGES;
And just call:
mysqld_safe --init-file=/root/mysql.reset.sql
Will be very helpful if you are in a habit of forgetting passwords often.
You could create a sql file say /root/mysql.reset.sql
with the content:
UPDATE mysql.user SET Password=PASSWORD('yourpassword') WHERE User='root';
FLUSH PRIVILEGES;
And just call:
mysqld_safe --init-file=/root/mysql.reset.sql
Will be very helpful if you are in a habit of forgetting passwords often.
edited Oct 5 '15 at 15:23
snoop
2,86762650
2,86762650
answered Dec 23 '11 at 6:29
tamilsweet
1413
1413
add a comment |
add a comment |
up vote
1
down vote
sudo dpkg-reconfigure mysql-server-5.5
you can use tab complete after mysql-server-
if you're using a different version of mysql.
add a comment |
up vote
1
down vote
sudo dpkg-reconfigure mysql-server-5.5
you can use tab complete after mysql-server-
if you're using a different version of mysql.
add a comment |
up vote
1
down vote
up vote
1
down vote
sudo dpkg-reconfigure mysql-server-5.5
you can use tab complete after mysql-server-
if you're using a different version of mysql.
sudo dpkg-reconfigure mysql-server-5.5
you can use tab complete after mysql-server-
if you're using a different version of mysql.
answered Jun 10 '12 at 16:54
Colin Pickard
123113
123113
add a comment |
add a comment |
up vote
1
down vote
tumbleweed's answer was the only one that helped me. I was dealing with what could possibly have been a corrupted root user and none of the standard methods resolved the issue of not being able to log in as root.
Using the debian-sys-maint user, I was able to finally log into MySQL with escalated privileges and even then resetting the root password did not work.
However, I was able to recreate the root user:
DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY '<newpassword>';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
... and finally all was right with the world again!
I hope that helps a desperate soul out there...
add a comment |
up vote
1
down vote
tumbleweed's answer was the only one that helped me. I was dealing with what could possibly have been a corrupted root user and none of the standard methods resolved the issue of not being able to log in as root.
Using the debian-sys-maint user, I was able to finally log into MySQL with escalated privileges and even then resetting the root password did not work.
However, I was able to recreate the root user:
DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY '<newpassword>';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
... and finally all was right with the world again!
I hope that helps a desperate soul out there...
add a comment |
up vote
1
down vote
up vote
1
down vote
tumbleweed's answer was the only one that helped me. I was dealing with what could possibly have been a corrupted root user and none of the standard methods resolved the issue of not being able to log in as root.
Using the debian-sys-maint user, I was able to finally log into MySQL with escalated privileges and even then resetting the root password did not work.
However, I was able to recreate the root user:
DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY '<newpassword>';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
... and finally all was right with the world again!
I hope that helps a desperate soul out there...
tumbleweed's answer was the only one that helped me. I was dealing with what could possibly have been a corrupted root user and none of the standard methods resolved the issue of not being able to log in as root.
Using the debian-sys-maint user, I was able to finally log into MySQL with escalated privileges and even then resetting the root password did not work.
However, I was able to recreate the root user:
DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY '<newpassword>';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
... and finally all was right with the world again!
I hope that helps a desperate soul out there...
answered Feb 9 '17 at 10:21
gopherIT
112
112
add a comment |
add a comment |
up vote
0
down vote
Stop the MySQL Server.
sudo /etc/init.d/mysql stop
Start the mysqld configuration.
sudo mysqld --skip-grant-tables &
Login to MySQL as root.
mysql -u root mysql
Replace YOURNEWPASSWORD with your new password!
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
add a comment |
up vote
0
down vote
Stop the MySQL Server.
sudo /etc/init.d/mysql stop
Start the mysqld configuration.
sudo mysqld --skip-grant-tables &
Login to MySQL as root.
mysql -u root mysql
Replace YOURNEWPASSWORD with your new password!
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
add a comment |
up vote
0
down vote
up vote
0
down vote
Stop the MySQL Server.
sudo /etc/init.d/mysql stop
Start the mysqld configuration.
sudo mysqld --skip-grant-tables &
Login to MySQL as root.
mysql -u root mysql
Replace YOURNEWPASSWORD with your new password!
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
Stop the MySQL Server.
sudo /etc/init.d/mysql stop
Start the mysqld configuration.
sudo mysqld --skip-grant-tables &
Login to MySQL as root.
mysql -u root mysql
Replace YOURNEWPASSWORD with your new password!
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
edited Feb 9 '17 at 11:30
Zanna
49.2k13123234
49.2k13123234
answered Feb 9 '17 at 10:45
Chetan Rathod
1
1
add a comment |
add a comment |
up vote
0
down vote
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
sudo mysql -u root
use mysql;
update user set authentication_string=PASSWORD("New_Passwore_Here") where User='root';
flush privileges;
exit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Hello and welcome to AU. Your answer might be correct but should be documented: it is not recommended to just give an instruction list. In this case, I do not see a problem but, in general, if a user mistypes something, it could lead to unwanted results. You also use 'sudo' even when it is not necessary (sudo mysql...
) which is potentially dangerous.
– Marc Vanhoomissen
May 14 at 12:02
add a comment |
up vote
0
down vote
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
sudo mysql -u root
use mysql;
update user set authentication_string=PASSWORD("New_Passwore_Here") where User='root';
flush privileges;
exit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Hello and welcome to AU. Your answer might be correct but should be documented: it is not recommended to just give an instruction list. In this case, I do not see a problem but, in general, if a user mistypes something, it could lead to unwanted results. You also use 'sudo' even when it is not necessary (sudo mysql...
) which is potentially dangerous.
– Marc Vanhoomissen
May 14 at 12:02
add a comment |
up vote
0
down vote
up vote
0
down vote
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
sudo mysql -u root
use mysql;
update user set authentication_string=PASSWORD("New_Passwore_Here") where User='root';
flush privileges;
exit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
sudo mysql -u root
use mysql;
update user set authentication_string=PASSWORD("New_Passwore_Here") where User='root';
flush privileges;
exit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
edited May 14 at 13:08
derHugo
2,25721428
2,25721428
answered May 14 at 11:47
samson mwanzia
1
1
Hello and welcome to AU. Your answer might be correct but should be documented: it is not recommended to just give an instruction list. In this case, I do not see a problem but, in general, if a user mistypes something, it could lead to unwanted results. You also use 'sudo' even when it is not necessary (sudo mysql...
) which is potentially dangerous.
– Marc Vanhoomissen
May 14 at 12:02
add a comment |
Hello and welcome to AU. Your answer might be correct but should be documented: it is not recommended to just give an instruction list. In this case, I do not see a problem but, in general, if a user mistypes something, it could lead to unwanted results. You also use 'sudo' even when it is not necessary (sudo mysql...
) which is potentially dangerous.
– Marc Vanhoomissen
May 14 at 12:02
Hello and welcome to AU. Your answer might be correct but should be documented: it is not recommended to just give an instruction list. In this case, I do not see a problem but, in general, if a user mistypes something, it could lead to unwanted results. You also use 'sudo' even when it is not necessary (
sudo mysql...
) which is potentially dangerous.– Marc Vanhoomissen
May 14 at 12:02
Hello and welcome to AU. Your answer might be correct but should be documented: it is not recommended to just give an instruction list. In this case, I do not see a problem but, in general, if a user mistypes something, it could lead to unwanted results. You also use 'sudo' even when it is not necessary (
sudo mysql...
) which is potentially dangerous.– Marc Vanhoomissen
May 14 at 12:02
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f89895%2fwhich-is-the-easiest-way-to-reset-the-mysql-root-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
second link look like the way to go
– Panther
Dec 23 '11 at 5:25