How to reset or change the MySQL root password?
How do I change the MySQL root password and username in ubuntu server? Do I need to stop the mysql service before setting any changes?
I have a phpmyadmin setup as well, will phpmyadmin get updated automatically?
mysql ubuntu phpmyadmin
add a comment |
How do I change the MySQL root password and username in ubuntu server? Do I need to stop the mysql service before setting any changes?
I have a phpmyadmin setup as well, will phpmyadmin get updated automatically?
mysql ubuntu phpmyadmin
If you don't need the data you can "reset" the password by removing mysql in its entirety: stackoverflow.com/questions/10853004/… then installing it again (it will prompt you for the "new" root password) FWIW :)
– rogerdpack
Jan 12 '18 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 '18 at 22:29
1
in mysql-server-5.7 these methods dont work. use 'sudo' without password as mentioned in askubuntu.com/a/848504
– Pragalathan M
May 13 '18 at 14:37
add a comment |
How do I change the MySQL root password and username in ubuntu server? Do I need to stop the mysql service before setting any changes?
I have a phpmyadmin setup as well, will phpmyadmin get updated automatically?
mysql ubuntu phpmyadmin
How do I change the MySQL root password and username in ubuntu server? Do I need to stop the mysql service before setting any changes?
I have a phpmyadmin setup as well, will phpmyadmin get updated automatically?
mysql ubuntu phpmyadmin
mysql ubuntu phpmyadmin
edited Sep 9 '14 at 7:42
Doomsday
2,1051727
2,1051727
asked May 15 '13 at 3:47
asm234asm234
7973915
7973915
If you don't need the data you can "reset" the password by removing mysql in its entirety: stackoverflow.com/questions/10853004/… then installing it again (it will prompt you for the "new" root password) FWIW :)
– rogerdpack
Jan 12 '18 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 '18 at 22:29
1
in mysql-server-5.7 these methods dont work. use 'sudo' without password as mentioned in askubuntu.com/a/848504
– Pragalathan M
May 13 '18 at 14:37
add a comment |
If you don't need the data you can "reset" the password by removing mysql in its entirety: stackoverflow.com/questions/10853004/… then installing it again (it will prompt you for the "new" root password) FWIW :)
– rogerdpack
Jan 12 '18 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 '18 at 22:29
1
in mysql-server-5.7 these methods dont work. use 'sudo' without password as mentioned in askubuntu.com/a/848504
– Pragalathan M
May 13 '18 at 14:37
If you don't need the data you can "reset" the password by removing mysql in its entirety: stackoverflow.com/questions/10853004/… then installing it again (it will prompt you for the "new" root password) FWIW :)
– rogerdpack
Jan 12 '18 at 22:33
If you don't need the data you can "reset" the password by removing mysql in its entirety: stackoverflow.com/questions/10853004/… then installing it again (it will prompt you for the "new" root password) FWIW :)
– rogerdpack
Jan 12 '18 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 '18 at 22:29
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 '18 at 22:29
1
1
in mysql-server-5.7 these methods dont work. use 'sudo' without password as mentioned in askubuntu.com/a/848504
– Pragalathan M
May 13 '18 at 14:37
in mysql-server-5.7 these methods dont work. use 'sudo' without password as mentioned in askubuntu.com/a/848504
– Pragalathan M
May 13 '18 at 14:37
add a comment |
27 Answers
27
active
oldest
votes
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.
- 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
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
password
column doesn't exist, you may want to try:UPDATE user SET authentication_string=password('YOURNEWPASSWORD') WHERE user='root';
Note: This method is not regarded as the most secure way of resetting the password, however, it works.
References:
- Set / Change / Reset the MySQL root password on Ubuntu Linux
- How to Reset the Root Password
13
Of course, after this point you'll need to kill the temporary, password-less server process that you started in step 2. maybe usesudo killall -9 mysqld
? and thensudo service mysql start
to restart the normal daemon...
– Lambart
Dec 8 '13 at 1:39
7
The method in this answer is only needed for resetting a MySQL root password that you don't know [source]. If you know it, theSET PASSWORD
MySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
41
i followed till 3rd step and i get Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when i login thru root
– Sushivam
Nov 2 '16 at 11:24
9
in some cases, you also need to runmkdir /var/run/mysqld
andchown mysql: /var/run/mysqld
between steps 1 and 2
– Neville Nazerane
Feb 2 '18 at 2:38
2
step 3 did not work for me with Ubuntu 18.04. I just logged in using sudo mysql
– itsols
Oct 24 '18 at 8:02
|
show 6 more comments
The official and easy way to reset the root password on an ubuntu server...
If you are on 16.04, 14.04, 12.04:
sudo dpkg-reconfigure mysql-server-5.5
If you are on 10.04:
sudo dpkg-reconfigure mysql-server-5.1
If you are not sure which mysql-server version is installed you can try:
dpkg --get-selections | grep mysql-server
Updated notes for mysql-server-5.7
Note that if you are using mysql-server-5.7 you can not use the easier dpkg-reconfigure method shown above.
If you know the password, login and run this:
UPDATE mysql.user SET authentication_string=PASSWORD('my-new-password') WHERE USER='root';
FLUSH PRIVILEGES;
Alternatively, you can use the following:
sudo mysql_secure_installation
This will ask you a series of questions about securing your installation (highly recommended), including if you want to provide a new root password.
If you do NOT know the root password, refer to this Ubuntu-centric write up on the process.
See for more info:
https://help.ubuntu.com/16.04/serverguide/mysql.html
https://help.ubuntu.com/14.04/serverguide/mysql.html
3
Works even when you lost the original MySQL root password – nice.
– tanius
May 2 '14 at 12:29
3
Works withVer 14.14 Distrib 5.5.38, for debian-linux-gnu
– justinpage
Sep 14 '14 at 1:56
This worked for me on 5.5.40-0ubuntu0.14.04.1
– ken koehler
Jan 15 '15 at 19:14
20
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
3
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 '18 at 6:25
|
show 1 more comment
The only method that worked for me is the one described here (I am running ubuntu 14.04). For the sake of clarity, these are the steps I followed:
sudo vim /etc/mysql/my.cnf
Add the following lines at the end:
[mysqld]
skip-grant-tables
sudo service mysql restart
mysql -u root
use mysql
select * from mysql.user where user = 'root';
- Look at the top to determine whether the password column is called
password or authentication_stringUPDATE mysql.user set *password_field from above* = PASSWORD('your_new_password') where user = 'root' and host = 'localhost';
- Use the proper password column from aboveFLUSH PRIVILEGES;
exit
sudo vim /etc/mysql/my.cnf
Remove the lines added in step 2 if you want to keep your security standards.
sudo service mysql restart
For reference : https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
5
Finally, this worked for me! I'm running MySQL 5.7.18 on Ubuntu 16.04. I tried dpkg-reconfigure, Anvesh's answer, Christian Mark's answer, and even the instructions on MySQL's help page.
– mbuc91
May 11 '17 at 5:15
8
I had to run UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root'; instead for line 5.
– mbuc91
May 11 '17 at 5:21
The only solution that worked for me. I have Ubuntu 17.04 and mysql 5.7
– Mohamed
Nov 20 '17 at 1:52
In point 6 you have to adduser
should be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 '18 at 2:50
1
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 '18 at 2:55
|
show 1 more comment
I am sharing the step by step final solution to reset a MySQL password in Linux
Ubuntu.
Reference taken from blog (dbrnd.com)
Step 1:
Stop MySQL Service.
sudo stop mysql
Step 2:
Kill all running mysqld.
sudo killall -9 mysqld
Step 3:
Starting mysqld in Safe mode.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Step 4:
Start mysql client
mysql -u root
Step 5:
After successful login, please execute this command to change any password.
FLUSH PRIVILEGES;
Step 6:
You can update mysql root password .
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
Note: On MySQL 5.7, column Password
is called authentication_string
.
Step 7:
Please execute this command.
FLUSH PRIVILEGES;
3
This actually worked for me, not the accepted answer, give it a try!
– Santiago Martí Olbrich
Oct 20 '15 at 14:49
Indeed. Also, it is closer to the official documentation. In case you run into this: "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded”, take a look at stackoverflow.com/questions/37879448/…
– Wtower
Aug 22 '16 at 9:36
I also had to change mysql.user.plugin from 'auth_socket' to 'mysql_native_password' for my root user with host of 'localhost'.
– Brandon
May 17 '17 at 2:16
1
I had to use "sudo /etc/init.d/mysql stop" to stop the service and "UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';" to update the password
– L Bahr
Aug 15 '17 at 1:55
1
authenticated _string helped
– Faiyaz Md Abdul
Nov 24 '17 at 17:49
add a comment |
Change the MySQL root password.
This method exposes the password to the command-line history, these commands should be run as root.
Login through mysql command line tool:
mysql -uroot -poldpassword
Run this command:
SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');
or
Run this command, which sets a password for the current user ('root' for this case) :
SET PASSWORD = PASSWORD('newpassword');
add a comment |
What worked for me (Ubuntu 16.04, mysql 5.7):
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
On another console, log in without a password.
mysql -uroot mysql
Then:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
The other ways did not work for me but this one (thanks!), or you can also go here rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts
– Dung
Dec 7 '17 at 17:25
7
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 '18 at 13:16
This didn't work in ubuntu 18.04. But it worked with this little change described here stackoverflow.com/a/53385753/1591143
– Aleksandar Popovic
Jan 19 at 16:16
add a comment |
I faced problems with ubuntu 18.04 and mysql 5.7, this is the solution
MYSQL-SERVER >= 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET authentication_string=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
MYSQL-SERVER < 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET password=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
1
Thanks, I'm also running Ubuntu 18.04 here and theMYSQL-SERVER >= 5.7
version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 '18 at 12:41
1
This is the one that worked for in Ubuntu 18.04 mysql installation.MYSQL-SERVER >= 5.7
version to be precise.
– Sathish Manohar
Feb 16 at 7:56
add a comment |
If you would like to change the MySQL root password, in a terminal enter:
sudo dpkg-reconfigure mysql-server-5.5
The MySQL daemon will be stopped, and you will be prompted to enter a new password.
1
This is a much better way to do it. I was unable to run the previous commands because of some mysql error...
– Andy
Jan 28 '16 at 3:46
sudo dpkg-reconfigure mysql-server-5.7 on ubuntu 16.04
– Nick Barrett
Feb 28 '17 at 6:42
1
I ransudo dpkg-reconfigure mysql-server-5.7
on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 '18 at 22:32
If it saysmysql-server is broken or not fully installed
, one can usesudo apt purge mysql*
andsudo apt install mysql-server
– Pavel
Oct 22 '18 at 7:30
add a comment |
This works like charm I did it for Ubuntu 16.04.
Full credit to below link as I got it from there.
[https://coderwall.com/p/j9btlg/reset-the-mysql-5-7-root-password-in-ubuntu-16-04-lts][1]
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Log in without a password.
mysql -uroot mysql
Update the password for the root user.
make sure at atleast root account gets updated by the below query.
make some selection and check the existing values if you like
UPDATE mysql.user SET
authentication_string=PASSWORD('YOURNEWPASSWORD'),
plugin='mysql_native_password' WHERE User='root';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
add a comment |
Stop MySQL
sudo service mysql stopMake MySQL service directory.
sudo mkdir /var/run/mysqldGive MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqldStart MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
5.Log in without a password.
mysql -uroot mysql
6.Update the password for the root user.
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdownStart the MySQL service normally.
sudo service mysql start
1
Hi, this answer works for me, but I had to use another command:UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
withoutAND Host='%'
. Thanks!
– David Corral
May 22 '18 at 17:51
add a comment |
This solution belongs to the previous version of MySQL.
By logging in to MySQL using socket authentication, you can do it.
sudo mysql -u root
Then the following command could be run.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Details are available here .
1
I couldn't login assudo mysql -u root
but I was able to do it assudo mysql
and run theALTER USER
command.
– itsols
Oct 24 '18 at 7:59
add a comment |
Echoing rogerdpack's comment: if you don't know the MySQL root password and you don't care about MySQL data/settings, you can reinstall it and reset the root's password as follows:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo rm -rf /var/lib/mysql
sudo apt-get install -y mysql-server mysql-client
During the installation, you can choose the root's password:
2
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 '18 at 23:23
add a comment |
This is the solution for me. I work at Ubuntu 18.04:
https://stackoverflow.com/a/46076838/2400373
But is important this change in the last step:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
add a comment |
If you know your current password, you don't have to stop mysql server.
Open the ubuntu terminal.
Login to mysql using:
mysql - username -p
Then type your password.
This will take you into the mysql console.
Inside the console, type:
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Then flush privileges using:
> flush privileges;
Then you are all done.
add a comment |
When you use MySQL's PASSWORD()
on the system where you want to change the password, it can cause the password turn up in a MySQL log in cleartext [source]. Keeping them, their backups etc. as secure as the password sounds like nightmare to me, so I rather like to do it as follows:
On your local machine, run this with your password:
mysql -u someuser -p < <(echo "SELECT PASSWORD('mypass');")
Note the space in front to prevent it from turning up in the bash history (for other distros than Ubuntu, this might work differently – source).
On your server machine, execute the following command to change its MySQL root password (replace
myhash
with your password's hash as printed by the first command):
mysql -u root -p < <(echo "SET PASSWORD FOR root@localhost = 'myhash';")
Optionally, let's be a bit paranoid: On your local machine, clear your terminal screen with
clear
and purge your virtual terminal scrollback, to hide the cleartext password appearing in the command above.
add a comment |
To update the "root" Mysql user password you must have in mind that you will need of super user permissions for that. If you have super user privilegies, try the following commands:
MySQL 5.7.6 and later
sudo su
service mysql stop
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
q;
exit
mysql -u root -p MyNewPass
MySQL 5.7.5 and earlier
sudo su
service mysql stop
mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
q;
exit
mysql -u root -p MyNewPass
add a comment |
Instead of resetting the password there is a work around on the local machine if you have setup phpmyadmin
to connect without giving the password or username. Check this out by starting mysql
, apache
etc. I have xampp
installed in my local machine. So starting the xampp will start all the necessary services. Now going to http://localhost/phpmyadmin
shows me all the databases. This confirms that you have saved the username and passsword in the config file of phpmyadmin which can be found in the phpmyadmin
install location. If you have xampp
installed the phpmyadmin
folder can be found in the root folder of xampp
installation. Search for the word password
in the config.inc.php
file. There you will find the password
and username
.
add a comment |
You can easily change the mysql password if deployed on xampp through provided phpadmin gui.
phpMyAdmin -> User Accounts -> Edit Privileges (Select the intended user) -> Change Password (Tab)
add a comment |
You can use this command :
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
after that pleas use flush
FLUSH PRIVILEGES;
add a comment |
for mysql 5.6 this command works and you can set password through the wizard:
sudo dpkg-reconfigure mysql-server-5.6
I tried but its not working.. I am getting this bellow error.. could you please help? This installation of MySQL is already upgraded to 5.7.21, use --force if you still need to run mysql_upgrade
– Vijaysinh Parmar
Mar 23 '18 at 7:30
add a comment |
You don't need all this. Simply log in:
mysql -u root -p
Then change the current user's password as the mysql>
prompt:
mysql> set password=password('the_new_password');
mysql> flush privileges;
add a comment |
You can try these some steps to reset mysql 5.7 root password :
Stop Mysql Service 1st
sudo /etc/init.d/mysql stop
Login as root without password
sudo mysqld_safe --skip-grant-tables
&
After login mysql terminal you should need execute commands more:
use mysql;
UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
flush privileges;
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
After you restart your mysql server
If you still facing error you must visit :
Reset MySQL 5.7 root password Ubuntu 16.04
add a comment |
when changing/resetting the MySQL password the following commands listed above did not help. I found that going into the terminal and using these commands is pointless. instead use the command sudo stop everything. DELETE SYSTEM 32 for windows if that helps.
1
The question is aboutubuntu
OS not windows. What do you mean by DELETE SYSTEM 32 for windows?
– EhsanT
Jan 14 '17 at 2:13
add a comment |
To reset or change the password enter sudo dpkg-reconfigure mysql-server-X.X
(X.X is mysql version you have installed i.e. 5.6, 5.7) and then you will prompt a screen where you have to set the new password and then in next step confirm the password and just wait for a moment. That's it.
add a comment |
I had to go this route on Ubuntu 16.04.1 LTS. It is somewhat of a mix of some of the other answers above - but none of them helped. I spent an hour or more trying all other suggestions from MySql website to everything on SO, I finally got it working with:
Note: while it showed Enter password for user root, I didnt have the original password so I just entered the same password to be used as the new password.
Note: there was no /var/log/mysqld.log only /var/log/mysql/error.log
Also note this did not work for me:
sudo dpkg-reconfigure mysql-server-5.7
Nor did:
sudo dpkg-reconfigure --force mysql-server-5.5
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Then:
- kill the current mysqld pid
- run mysqld with sudo /usr/sbin/mysqld &
run /usr/bin/mysql_secure_installation
Output from mysql_secure_installation
root@myServer:~# /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: no
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Dropping test database...
Success.Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
add a comment |
As mysql documentation on the password() function says:
This function was removed in MySQL 8.0.11.
This invalidates pretty much all existing answers for mysql v8.0.11 and newer.
Per mysql documentation the new generic way to reset the root password is as follows:
The preceding sections provide password-resetting instructions
specifically for Windows and Unix and Unix-like systems.
Alternatively, on any platform, you can reset the password using the
mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the
--skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management
statements such as ALTER USER and SET PASSWORD. Because this is
insecure, if the server is started with the --skip-grant-tables
option, it enables --skip-networking automatically to prevent remote
connections.
Connect to the MySQL server using the mysql client; no password is
necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.
To change the password for a root account with a different host name
part, modify the instructions to use that host name.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
You should now be able to connect to the MySQL server as root using the
new password. Stop the server and restart it normally (without the
--skip-grant-tables and --skip-networking options).
add a comment |
Change the MySQL root password. In Simpler way
All these commands should be run as root.
Login through MySQL command line tool using your old password:
Step-1
mysql -uroot -p"your_old_password"
Then run below command:
Step-2
SET PASSWORD FOR root@'localhost' = PASSWORD('your_new_password');
Method-2 (First login using your old password using above command)
Run this command, which sets a password for the current user:
SET PASSWORD = PASSWORD('your_new_password');
Above command is for the current user. If you want to change the password for other user, you can put the user name instead of "root".
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2fstackoverflow.com%2fquestions%2f16556497%2fhow-to-reset-or-change-the-mysql-root-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
27 Answers
27
active
oldest
votes
27 Answers
27
active
oldest
votes
active
oldest
votes
active
oldest
votes
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.
- 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
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
password
column doesn't exist, you may want to try:UPDATE user SET authentication_string=password('YOURNEWPASSWORD') WHERE user='root';
Note: This method is not regarded as the most secure way of resetting the password, however, it works.
References:
- Set / Change / Reset the MySQL root password on Ubuntu Linux
- How to Reset the Root Password
13
Of course, after this point you'll need to kill the temporary, password-less server process that you started in step 2. maybe usesudo killall -9 mysqld
? and thensudo service mysql start
to restart the normal daemon...
– Lambart
Dec 8 '13 at 1:39
7
The method in this answer is only needed for resetting a MySQL root password that you don't know [source]. If you know it, theSET PASSWORD
MySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
41
i followed till 3rd step and i get Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when i login thru root
– Sushivam
Nov 2 '16 at 11:24
9
in some cases, you also need to runmkdir /var/run/mysqld
andchown mysql: /var/run/mysqld
between steps 1 and 2
– Neville Nazerane
Feb 2 '18 at 2:38
2
step 3 did not work for me with Ubuntu 18.04. I just logged in using sudo mysql
– itsols
Oct 24 '18 at 8:02
|
show 6 more comments
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.
- 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
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
password
column doesn't exist, you may want to try:UPDATE user SET authentication_string=password('YOURNEWPASSWORD') WHERE user='root';
Note: This method is not regarded as the most secure way of resetting the password, however, it works.
References:
- Set / Change / Reset the MySQL root password on Ubuntu Linux
- How to Reset the Root Password
13
Of course, after this point you'll need to kill the temporary, password-less server process that you started in step 2. maybe usesudo killall -9 mysqld
? and thensudo service mysql start
to restart the normal daemon...
– Lambart
Dec 8 '13 at 1:39
7
The method in this answer is only needed for resetting a MySQL root password that you don't know [source]. If you know it, theSET PASSWORD
MySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
41
i followed till 3rd step and i get Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when i login thru root
– Sushivam
Nov 2 '16 at 11:24
9
in some cases, you also need to runmkdir /var/run/mysqld
andchown mysql: /var/run/mysqld
between steps 1 and 2
– Neville Nazerane
Feb 2 '18 at 2:38
2
step 3 did not work for me with Ubuntu 18.04. I just logged in using sudo mysql
– itsols
Oct 24 '18 at 8:02
|
show 6 more comments
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.
- 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
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
password
column doesn't exist, you may want to try:UPDATE user SET authentication_string=password('YOURNEWPASSWORD') WHERE user='root';
Note: This method is not regarded as the most secure way of resetting the password, however, it works.
References:
- Set / Change / Reset the MySQL root password on Ubuntu Linux
- How to Reset the Root Password
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.
- 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
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
password
column doesn't exist, you may want to try:UPDATE user SET authentication_string=password('YOURNEWPASSWORD') WHERE user='root';
Note: This method is not regarded as the most secure way of resetting the password, however, it works.
References:
- Set / Change / Reset the MySQL root password on Ubuntu Linux
- How to Reset the Root Password
edited May 17 '18 at 3:09
Lemayzeur
5,2701833
5,2701833
answered May 15 '13 at 3:52
Christian MarkChristian Mark
5,481133474
5,481133474
13
Of course, after this point you'll need to kill the temporary, password-less server process that you started in step 2. maybe usesudo killall -9 mysqld
? and thensudo service mysql start
to restart the normal daemon...
– Lambart
Dec 8 '13 at 1:39
7
The method in this answer is only needed for resetting a MySQL root password that you don't know [source]. If you know it, theSET PASSWORD
MySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
41
i followed till 3rd step and i get Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when i login thru root
– Sushivam
Nov 2 '16 at 11:24
9
in some cases, you also need to runmkdir /var/run/mysqld
andchown mysql: /var/run/mysqld
between steps 1 and 2
– Neville Nazerane
Feb 2 '18 at 2:38
2
step 3 did not work for me with Ubuntu 18.04. I just logged in using sudo mysql
– itsols
Oct 24 '18 at 8:02
|
show 6 more comments
13
Of course, after this point you'll need to kill the temporary, password-less server process that you started in step 2. maybe usesudo killall -9 mysqld
? and thensudo service mysql start
to restart the normal daemon...
– Lambart
Dec 8 '13 at 1:39
7
The method in this answer is only needed for resetting a MySQL root password that you don't know [source]. If you know it, theSET PASSWORD
MySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
41
i followed till 3rd step and i get Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when i login thru root
– Sushivam
Nov 2 '16 at 11:24
9
in some cases, you also need to runmkdir /var/run/mysqld
andchown mysql: /var/run/mysqld
between steps 1 and 2
– Neville Nazerane
Feb 2 '18 at 2:38
2
step 3 did not work for me with Ubuntu 18.04. I just logged in using sudo mysql
– itsols
Oct 24 '18 at 8:02
13
13
Of course, after this point you'll need to kill the temporary, password-less server process that you started in step 2. maybe use
sudo killall -9 mysqld
? and then sudo service mysql start
to restart the normal daemon...– Lambart
Dec 8 '13 at 1:39
Of course, after this point you'll need to kill the temporary, password-less server process that you started in step 2. maybe use
sudo killall -9 mysqld
? and then sudo service mysql start
to restart the normal daemon...– Lambart
Dec 8 '13 at 1:39
7
7
The method in this answer is only needed for resetting a MySQL root password that you don't know [source]. If you know it, the
SET PASSWORD
MySQL instruction is for you.– tanius
Mar 6 '14 at 17:51
The method in this answer is only needed for resetting a MySQL root password that you don't know [source]. If you know it, the
SET PASSWORD
MySQL instruction is for you.– tanius
Mar 6 '14 at 17:51
41
41
i followed till 3rd step and i get Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when i login thru root
– Sushivam
Nov 2 '16 at 11:24
i followed till 3rd step and i get Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when i login thru root
– Sushivam
Nov 2 '16 at 11:24
9
9
in some cases, you also need to run
mkdir /var/run/mysqld
and chown mysql: /var/run/mysqld
between steps 1 and 2– Neville Nazerane
Feb 2 '18 at 2:38
in some cases, you also need to run
mkdir /var/run/mysqld
and chown mysql: /var/run/mysqld
between steps 1 and 2– Neville Nazerane
Feb 2 '18 at 2:38
2
2
step 3 did not work for me with Ubuntu 18.04. I just logged in using sudo mysql
– itsols
Oct 24 '18 at 8:02
step 3 did not work for me with Ubuntu 18.04. I just logged in using sudo mysql
– itsols
Oct 24 '18 at 8:02
|
show 6 more comments
The official and easy way to reset the root password on an ubuntu server...
If you are on 16.04, 14.04, 12.04:
sudo dpkg-reconfigure mysql-server-5.5
If you are on 10.04:
sudo dpkg-reconfigure mysql-server-5.1
If you are not sure which mysql-server version is installed you can try:
dpkg --get-selections | grep mysql-server
Updated notes for mysql-server-5.7
Note that if you are using mysql-server-5.7 you can not use the easier dpkg-reconfigure method shown above.
If you know the password, login and run this:
UPDATE mysql.user SET authentication_string=PASSWORD('my-new-password') WHERE USER='root';
FLUSH PRIVILEGES;
Alternatively, you can use the following:
sudo mysql_secure_installation
This will ask you a series of questions about securing your installation (highly recommended), including if you want to provide a new root password.
If you do NOT know the root password, refer to this Ubuntu-centric write up on the process.
See for more info:
https://help.ubuntu.com/16.04/serverguide/mysql.html
https://help.ubuntu.com/14.04/serverguide/mysql.html
3
Works even when you lost the original MySQL root password – nice.
– tanius
May 2 '14 at 12:29
3
Works withVer 14.14 Distrib 5.5.38, for debian-linux-gnu
– justinpage
Sep 14 '14 at 1:56
This worked for me on 5.5.40-0ubuntu0.14.04.1
– ken koehler
Jan 15 '15 at 19:14
20
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
3
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 '18 at 6:25
|
show 1 more comment
The official and easy way to reset the root password on an ubuntu server...
If you are on 16.04, 14.04, 12.04:
sudo dpkg-reconfigure mysql-server-5.5
If you are on 10.04:
sudo dpkg-reconfigure mysql-server-5.1
If you are not sure which mysql-server version is installed you can try:
dpkg --get-selections | grep mysql-server
Updated notes for mysql-server-5.7
Note that if you are using mysql-server-5.7 you can not use the easier dpkg-reconfigure method shown above.
If you know the password, login and run this:
UPDATE mysql.user SET authentication_string=PASSWORD('my-new-password') WHERE USER='root';
FLUSH PRIVILEGES;
Alternatively, you can use the following:
sudo mysql_secure_installation
This will ask you a series of questions about securing your installation (highly recommended), including if you want to provide a new root password.
If you do NOT know the root password, refer to this Ubuntu-centric write up on the process.
See for more info:
https://help.ubuntu.com/16.04/serverguide/mysql.html
https://help.ubuntu.com/14.04/serverguide/mysql.html
3
Works even when you lost the original MySQL root password – nice.
– tanius
May 2 '14 at 12:29
3
Works withVer 14.14 Distrib 5.5.38, for debian-linux-gnu
– justinpage
Sep 14 '14 at 1:56
This worked for me on 5.5.40-0ubuntu0.14.04.1
– ken koehler
Jan 15 '15 at 19:14
20
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
3
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 '18 at 6:25
|
show 1 more comment
The official and easy way to reset the root password on an ubuntu server...
If you are on 16.04, 14.04, 12.04:
sudo dpkg-reconfigure mysql-server-5.5
If you are on 10.04:
sudo dpkg-reconfigure mysql-server-5.1
If you are not sure which mysql-server version is installed you can try:
dpkg --get-selections | grep mysql-server
Updated notes for mysql-server-5.7
Note that if you are using mysql-server-5.7 you can not use the easier dpkg-reconfigure method shown above.
If you know the password, login and run this:
UPDATE mysql.user SET authentication_string=PASSWORD('my-new-password') WHERE USER='root';
FLUSH PRIVILEGES;
Alternatively, you can use the following:
sudo mysql_secure_installation
This will ask you a series of questions about securing your installation (highly recommended), including if you want to provide a new root password.
If you do NOT know the root password, refer to this Ubuntu-centric write up on the process.
See for more info:
https://help.ubuntu.com/16.04/serverguide/mysql.html
https://help.ubuntu.com/14.04/serverguide/mysql.html
The official and easy way to reset the root password on an ubuntu server...
If you are on 16.04, 14.04, 12.04:
sudo dpkg-reconfigure mysql-server-5.5
If you are on 10.04:
sudo dpkg-reconfigure mysql-server-5.1
If you are not sure which mysql-server version is installed you can try:
dpkg --get-selections | grep mysql-server
Updated notes for mysql-server-5.7
Note that if you are using mysql-server-5.7 you can not use the easier dpkg-reconfigure method shown above.
If you know the password, login and run this:
UPDATE mysql.user SET authentication_string=PASSWORD('my-new-password') WHERE USER='root';
FLUSH PRIVILEGES;
Alternatively, you can use the following:
sudo mysql_secure_installation
This will ask you a series of questions about securing your installation (highly recommended), including if you want to provide a new root password.
If you do NOT know the root password, refer to this Ubuntu-centric write up on the process.
See for more info:
https://help.ubuntu.com/16.04/serverguide/mysql.html
https://help.ubuntu.com/14.04/serverguide/mysql.html
edited Dec 6 '17 at 5:00
answered Mar 27 '14 at 3:57
user12345user12345
1,68911617
1,68911617
3
Works even when you lost the original MySQL root password – nice.
– tanius
May 2 '14 at 12:29
3
Works withVer 14.14 Distrib 5.5.38, for debian-linux-gnu
– justinpage
Sep 14 '14 at 1:56
This worked for me on 5.5.40-0ubuntu0.14.04.1
– ken koehler
Jan 15 '15 at 19:14
20
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
3
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 '18 at 6:25
|
show 1 more comment
3
Works even when you lost the original MySQL root password – nice.
– tanius
May 2 '14 at 12:29
3
Works withVer 14.14 Distrib 5.5.38, for debian-linux-gnu
– justinpage
Sep 14 '14 at 1:56
This worked for me on 5.5.40-0ubuntu0.14.04.1
– ken koehler
Jan 15 '15 at 19:14
20
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
3
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 '18 at 6:25
3
3
Works even when you lost the original MySQL root password – nice.
– tanius
May 2 '14 at 12:29
Works even when you lost the original MySQL root password – nice.
– tanius
May 2 '14 at 12:29
3
3
Works with
Ver 14.14 Distrib 5.5.38, for debian-linux-gnu
– justinpage
Sep 14 '14 at 1:56
Works with
Ver 14.14 Distrib 5.5.38, for debian-linux-gnu
– justinpage
Sep 14 '14 at 1:56
This worked for me on 5.5.40-0ubuntu0.14.04.1
– ken koehler
Jan 15 '15 at 19:14
This worked for me on 5.5.40-0ubuntu0.14.04.1
– ken koehler
Jan 15 '15 at 19:14
20
20
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
3
3
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 '18 at 6:25
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 '18 at 6:25
|
show 1 more comment
The only method that worked for me is the one described here (I am running ubuntu 14.04). For the sake of clarity, these are the steps I followed:
sudo vim /etc/mysql/my.cnf
Add the following lines at the end:
[mysqld]
skip-grant-tables
sudo service mysql restart
mysql -u root
use mysql
select * from mysql.user where user = 'root';
- Look at the top to determine whether the password column is called
password or authentication_stringUPDATE mysql.user set *password_field from above* = PASSWORD('your_new_password') where user = 'root' and host = 'localhost';
- Use the proper password column from aboveFLUSH PRIVILEGES;
exit
sudo vim /etc/mysql/my.cnf
Remove the lines added in step 2 if you want to keep your security standards.
sudo service mysql restart
For reference : https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
5
Finally, this worked for me! I'm running MySQL 5.7.18 on Ubuntu 16.04. I tried dpkg-reconfigure, Anvesh's answer, Christian Mark's answer, and even the instructions on MySQL's help page.
– mbuc91
May 11 '17 at 5:15
8
I had to run UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root'; instead for line 5.
– mbuc91
May 11 '17 at 5:21
The only solution that worked for me. I have Ubuntu 17.04 and mysql 5.7
– Mohamed
Nov 20 '17 at 1:52
In point 6 you have to adduser
should be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 '18 at 2:50
1
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 '18 at 2:55
|
show 1 more comment
The only method that worked for me is the one described here (I am running ubuntu 14.04). For the sake of clarity, these are the steps I followed:
sudo vim /etc/mysql/my.cnf
Add the following lines at the end:
[mysqld]
skip-grant-tables
sudo service mysql restart
mysql -u root
use mysql
select * from mysql.user where user = 'root';
- Look at the top to determine whether the password column is called
password or authentication_stringUPDATE mysql.user set *password_field from above* = PASSWORD('your_new_password') where user = 'root' and host = 'localhost';
- Use the proper password column from aboveFLUSH PRIVILEGES;
exit
sudo vim /etc/mysql/my.cnf
Remove the lines added in step 2 if you want to keep your security standards.
sudo service mysql restart
For reference : https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
5
Finally, this worked for me! I'm running MySQL 5.7.18 on Ubuntu 16.04. I tried dpkg-reconfigure, Anvesh's answer, Christian Mark's answer, and even the instructions on MySQL's help page.
– mbuc91
May 11 '17 at 5:15
8
I had to run UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root'; instead for line 5.
– mbuc91
May 11 '17 at 5:21
The only solution that worked for me. I have Ubuntu 17.04 and mysql 5.7
– Mohamed
Nov 20 '17 at 1:52
In point 6 you have to adduser
should be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 '18 at 2:50
1
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 '18 at 2:55
|
show 1 more comment
The only method that worked for me is the one described here (I am running ubuntu 14.04). For the sake of clarity, these are the steps I followed:
sudo vim /etc/mysql/my.cnf
Add the following lines at the end:
[mysqld]
skip-grant-tables
sudo service mysql restart
mysql -u root
use mysql
select * from mysql.user where user = 'root';
- Look at the top to determine whether the password column is called
password or authentication_stringUPDATE mysql.user set *password_field from above* = PASSWORD('your_new_password') where user = 'root' and host = 'localhost';
- Use the proper password column from aboveFLUSH PRIVILEGES;
exit
sudo vim /etc/mysql/my.cnf
Remove the lines added in step 2 if you want to keep your security standards.
sudo service mysql restart
For reference : https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
The only method that worked for me is the one described here (I am running ubuntu 14.04). For the sake of clarity, these are the steps I followed:
sudo vim /etc/mysql/my.cnf
Add the following lines at the end:
[mysqld]
skip-grant-tables
sudo service mysql restart
mysql -u root
use mysql
select * from mysql.user where user = 'root';
- Look at the top to determine whether the password column is called
password or authentication_stringUPDATE mysql.user set *password_field from above* = PASSWORD('your_new_password') where user = 'root' and host = 'localhost';
- Use the proper password column from aboveFLUSH PRIVILEGES;
exit
sudo vim /etc/mysql/my.cnf
Remove the lines added in step 2 if you want to keep your security standards.
sudo service mysql restart
For reference : https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
edited Jun 5 '18 at 13:07
Ravindra Gullapalli
7,86433161
7,86433161
answered Jul 31 '15 at 17:28
narkonarko
1,5971824
1,5971824
5
Finally, this worked for me! I'm running MySQL 5.7.18 on Ubuntu 16.04. I tried dpkg-reconfigure, Anvesh's answer, Christian Mark's answer, and even the instructions on MySQL's help page.
– mbuc91
May 11 '17 at 5:15
8
I had to run UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root'; instead for line 5.
– mbuc91
May 11 '17 at 5:21
The only solution that worked for me. I have Ubuntu 17.04 and mysql 5.7
– Mohamed
Nov 20 '17 at 1:52
In point 6 you have to adduser
should be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 '18 at 2:50
1
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 '18 at 2:55
|
show 1 more comment
5
Finally, this worked for me! I'm running MySQL 5.7.18 on Ubuntu 16.04. I tried dpkg-reconfigure, Anvesh's answer, Christian Mark's answer, and even the instructions on MySQL's help page.
– mbuc91
May 11 '17 at 5:15
8
I had to run UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root'; instead for line 5.
– mbuc91
May 11 '17 at 5:21
The only solution that worked for me. I have Ubuntu 17.04 and mysql 5.7
– Mohamed
Nov 20 '17 at 1:52
In point 6 you have to adduser
should be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 '18 at 2:50
1
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 '18 at 2:55
5
5
Finally, this worked for me! I'm running MySQL 5.7.18 on Ubuntu 16.04. I tried dpkg-reconfigure, Anvesh's answer, Christian Mark's answer, and even the instructions on MySQL's help page.
– mbuc91
May 11 '17 at 5:15
Finally, this worked for me! I'm running MySQL 5.7.18 on Ubuntu 16.04. I tried dpkg-reconfigure, Anvesh's answer, Christian Mark's answer, and even the instructions on MySQL's help page.
– mbuc91
May 11 '17 at 5:15
8
8
I had to run UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root'; instead for line 5.
– mbuc91
May 11 '17 at 5:21
I had to run UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root'; instead for line 5.
– mbuc91
May 11 '17 at 5:21
The only solution that worked for me. I have Ubuntu 17.04 and mysql 5.7
– Mohamed
Nov 20 '17 at 1:52
The only solution that worked for me. I have Ubuntu 17.04 and mysql 5.7
– Mohamed
Nov 20 '17 at 1:52
In point 6 you have to add
user
should be this way select * from mysql.user where user = 'root';
– user615274
May 17 '18 at 2:50
In point 6 you have to add
user
should be this way select * from mysql.user where user = 'root';
– user615274
May 17 '18 at 2:50
1
1
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 '18 at 2:55
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 '18 at 2:55
|
show 1 more comment
I am sharing the step by step final solution to reset a MySQL password in Linux
Ubuntu.
Reference taken from blog (dbrnd.com)
Step 1:
Stop MySQL Service.
sudo stop mysql
Step 2:
Kill all running mysqld.
sudo killall -9 mysqld
Step 3:
Starting mysqld in Safe mode.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Step 4:
Start mysql client
mysql -u root
Step 5:
After successful login, please execute this command to change any password.
FLUSH PRIVILEGES;
Step 6:
You can update mysql root password .
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
Note: On MySQL 5.7, column Password
is called authentication_string
.
Step 7:
Please execute this command.
FLUSH PRIVILEGES;
3
This actually worked for me, not the accepted answer, give it a try!
– Santiago Martí Olbrich
Oct 20 '15 at 14:49
Indeed. Also, it is closer to the official documentation. In case you run into this: "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded”, take a look at stackoverflow.com/questions/37879448/…
– Wtower
Aug 22 '16 at 9:36
I also had to change mysql.user.plugin from 'auth_socket' to 'mysql_native_password' for my root user with host of 'localhost'.
– Brandon
May 17 '17 at 2:16
1
I had to use "sudo /etc/init.d/mysql stop" to stop the service and "UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';" to update the password
– L Bahr
Aug 15 '17 at 1:55
1
authenticated _string helped
– Faiyaz Md Abdul
Nov 24 '17 at 17:49
add a comment |
I am sharing the step by step final solution to reset a MySQL password in Linux
Ubuntu.
Reference taken from blog (dbrnd.com)
Step 1:
Stop MySQL Service.
sudo stop mysql
Step 2:
Kill all running mysqld.
sudo killall -9 mysqld
Step 3:
Starting mysqld in Safe mode.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Step 4:
Start mysql client
mysql -u root
Step 5:
After successful login, please execute this command to change any password.
FLUSH PRIVILEGES;
Step 6:
You can update mysql root password .
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
Note: On MySQL 5.7, column Password
is called authentication_string
.
Step 7:
Please execute this command.
FLUSH PRIVILEGES;
3
This actually worked for me, not the accepted answer, give it a try!
– Santiago Martí Olbrich
Oct 20 '15 at 14:49
Indeed. Also, it is closer to the official documentation. In case you run into this: "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded”, take a look at stackoverflow.com/questions/37879448/…
– Wtower
Aug 22 '16 at 9:36
I also had to change mysql.user.plugin from 'auth_socket' to 'mysql_native_password' for my root user with host of 'localhost'.
– Brandon
May 17 '17 at 2:16
1
I had to use "sudo /etc/init.d/mysql stop" to stop the service and "UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';" to update the password
– L Bahr
Aug 15 '17 at 1:55
1
authenticated _string helped
– Faiyaz Md Abdul
Nov 24 '17 at 17:49
add a comment |
I am sharing the step by step final solution to reset a MySQL password in Linux
Ubuntu.
Reference taken from blog (dbrnd.com)
Step 1:
Stop MySQL Service.
sudo stop mysql
Step 2:
Kill all running mysqld.
sudo killall -9 mysqld
Step 3:
Starting mysqld in Safe mode.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Step 4:
Start mysql client
mysql -u root
Step 5:
After successful login, please execute this command to change any password.
FLUSH PRIVILEGES;
Step 6:
You can update mysql root password .
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
Note: On MySQL 5.7, column Password
is called authentication_string
.
Step 7:
Please execute this command.
FLUSH PRIVILEGES;
I am sharing the step by step final solution to reset a MySQL password in Linux
Ubuntu.
Reference taken from blog (dbrnd.com)
Step 1:
Stop MySQL Service.
sudo stop mysql
Step 2:
Kill all running mysqld.
sudo killall -9 mysqld
Step 3:
Starting mysqld in Safe mode.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Step 4:
Start mysql client
mysql -u root
Step 5:
After successful login, please execute this command to change any password.
FLUSH PRIVILEGES;
Step 6:
You can update mysql root password .
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
Note: On MySQL 5.7, column Password
is called authentication_string
.
Step 7:
Please execute this command.
FLUSH PRIVILEGES;
edited Nov 15 '16 at 7:59
answered Sep 8 '15 at 5:03
AnveshAnvesh
3,39622736
3,39622736
3
This actually worked for me, not the accepted answer, give it a try!
– Santiago Martí Olbrich
Oct 20 '15 at 14:49
Indeed. Also, it is closer to the official documentation. In case you run into this: "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded”, take a look at stackoverflow.com/questions/37879448/…
– Wtower
Aug 22 '16 at 9:36
I also had to change mysql.user.plugin from 'auth_socket' to 'mysql_native_password' for my root user with host of 'localhost'.
– Brandon
May 17 '17 at 2:16
1
I had to use "sudo /etc/init.d/mysql stop" to stop the service and "UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';" to update the password
– L Bahr
Aug 15 '17 at 1:55
1
authenticated _string helped
– Faiyaz Md Abdul
Nov 24 '17 at 17:49
add a comment |
3
This actually worked for me, not the accepted answer, give it a try!
– Santiago Martí Olbrich
Oct 20 '15 at 14:49
Indeed. Also, it is closer to the official documentation. In case you run into this: "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded”, take a look at stackoverflow.com/questions/37879448/…
– Wtower
Aug 22 '16 at 9:36
I also had to change mysql.user.plugin from 'auth_socket' to 'mysql_native_password' for my root user with host of 'localhost'.
– Brandon
May 17 '17 at 2:16
1
I had to use "sudo /etc/init.d/mysql stop" to stop the service and "UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';" to update the password
– L Bahr
Aug 15 '17 at 1:55
1
authenticated _string helped
– Faiyaz Md Abdul
Nov 24 '17 at 17:49
3
3
This actually worked for me, not the accepted answer, give it a try!
– Santiago Martí Olbrich
Oct 20 '15 at 14:49
This actually worked for me, not the accepted answer, give it a try!
– Santiago Martí Olbrich
Oct 20 '15 at 14:49
Indeed. Also, it is closer to the official documentation. In case you run into this: "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded”, take a look at stackoverflow.com/questions/37879448/…
– Wtower
Aug 22 '16 at 9:36
Indeed. Also, it is closer to the official documentation. In case you run into this: "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded”, take a look at stackoverflow.com/questions/37879448/…
– Wtower
Aug 22 '16 at 9:36
I also had to change mysql.user.plugin from 'auth_socket' to 'mysql_native_password' for my root user with host of 'localhost'.
– Brandon
May 17 '17 at 2:16
I also had to change mysql.user.plugin from 'auth_socket' to 'mysql_native_password' for my root user with host of 'localhost'.
– Brandon
May 17 '17 at 2:16
1
1
I had to use "sudo /etc/init.d/mysql stop" to stop the service and "UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';" to update the password
– L Bahr
Aug 15 '17 at 1:55
I had to use "sudo /etc/init.d/mysql stop" to stop the service and "UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';" to update the password
– L Bahr
Aug 15 '17 at 1:55
1
1
authenticated _string helped
– Faiyaz Md Abdul
Nov 24 '17 at 17:49
authenticated _string helped
– Faiyaz Md Abdul
Nov 24 '17 at 17:49
add a comment |
Change the MySQL root password.
This method exposes the password to the command-line history, these commands should be run as root.
Login through mysql command line tool:
mysql -uroot -poldpassword
Run this command:
SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');
or
Run this command, which sets a password for the current user ('root' for this case) :
SET PASSWORD = PASSWORD('newpassword');
add a comment |
Change the MySQL root password.
This method exposes the password to the command-line history, these commands should be run as root.
Login through mysql command line tool:
mysql -uroot -poldpassword
Run this command:
SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');
or
Run this command, which sets a password for the current user ('root' for this case) :
SET PASSWORD = PASSWORD('newpassword');
add a comment |
Change the MySQL root password.
This method exposes the password to the command-line history, these commands should be run as root.
Login through mysql command line tool:
mysql -uroot -poldpassword
Run this command:
SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');
or
Run this command, which sets a password for the current user ('root' for this case) :
SET PASSWORD = PASSWORD('newpassword');
Change the MySQL root password.
This method exposes the password to the command-line history, these commands should be run as root.
Login through mysql command line tool:
mysql -uroot -poldpassword
Run this command:
SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');
or
Run this command, which sets a password for the current user ('root' for this case) :
SET PASSWORD = PASSWORD('newpassword');
edited Sep 10 '14 at 14:29
Logan Murphy
4,55321835
4,55321835
answered Oct 26 '13 at 20:22
faisalbhagatfaisalbhagat
1,6641824
1,6641824
add a comment |
add a comment |
What worked for me (Ubuntu 16.04, mysql 5.7):
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
On another console, log in without a password.
mysql -uroot mysql
Then:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
The other ways did not work for me but this one (thanks!), or you can also go here rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts
– Dung
Dec 7 '17 at 17:25
7
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 '18 at 13:16
This didn't work in ubuntu 18.04. But it worked with this little change described here stackoverflow.com/a/53385753/1591143
– Aleksandar Popovic
Jan 19 at 16:16
add a comment |
What worked for me (Ubuntu 16.04, mysql 5.7):
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
On another console, log in without a password.
mysql -uroot mysql
Then:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
The other ways did not work for me but this one (thanks!), or you can also go here rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts
– Dung
Dec 7 '17 at 17:25
7
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 '18 at 13:16
This didn't work in ubuntu 18.04. But it worked with this little change described here stackoverflow.com/a/53385753/1591143
– Aleksandar Popovic
Jan 19 at 16:16
add a comment |
What worked for me (Ubuntu 16.04, mysql 5.7):
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
On another console, log in without a password.
mysql -uroot mysql
Then:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
What worked for me (Ubuntu 16.04, mysql 5.7):
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
On another console, log in without a password.
mysql -uroot mysql
Then:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
answered Sep 6 '17 at 13:41
fabriciofreitagfabriciofreitag
1,323816
1,323816
The other ways did not work for me but this one (thanks!), or you can also go here rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts
– Dung
Dec 7 '17 at 17:25
7
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 '18 at 13:16
This didn't work in ubuntu 18.04. But it worked with this little change described here stackoverflow.com/a/53385753/1591143
– Aleksandar Popovic
Jan 19 at 16:16
add a comment |
The other ways did not work for me but this one (thanks!), or you can also go here rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts
– Dung
Dec 7 '17 at 17:25
7
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 '18 at 13:16
This didn't work in ubuntu 18.04. But it worked with this little change described here stackoverflow.com/a/53385753/1591143
– Aleksandar Popovic
Jan 19 at 16:16
The other ways did not work for me but this one (thanks!), or you can also go here rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts
– Dung
Dec 7 '17 at 17:25
The other ways did not work for me but this one (thanks!), or you can also go here rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts
– Dung
Dec 7 '17 at 17:25
7
7
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 '18 at 13:16
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 '18 at 13:16
This didn't work in ubuntu 18.04. But it worked with this little change described here stackoverflow.com/a/53385753/1591143
– Aleksandar Popovic
Jan 19 at 16:16
This didn't work in ubuntu 18.04. But it worked with this little change described here stackoverflow.com/a/53385753/1591143
– Aleksandar Popovic
Jan 19 at 16:16
add a comment |
I faced problems with ubuntu 18.04 and mysql 5.7, this is the solution
MYSQL-SERVER >= 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET authentication_string=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
MYSQL-SERVER < 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET password=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
1
Thanks, I'm also running Ubuntu 18.04 here and theMYSQL-SERVER >= 5.7
version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 '18 at 12:41
1
This is the one that worked for in Ubuntu 18.04 mysql installation.MYSQL-SERVER >= 5.7
version to be precise.
– Sathish Manohar
Feb 16 at 7:56
add a comment |
I faced problems with ubuntu 18.04 and mysql 5.7, this is the solution
MYSQL-SERVER >= 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET authentication_string=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
MYSQL-SERVER < 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET password=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
1
Thanks, I'm also running Ubuntu 18.04 here and theMYSQL-SERVER >= 5.7
version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 '18 at 12:41
1
This is the one that worked for in Ubuntu 18.04 mysql installation.MYSQL-SERVER >= 5.7
version to be precise.
– Sathish Manohar
Feb 16 at 7:56
add a comment |
I faced problems with ubuntu 18.04 and mysql 5.7, this is the solution
MYSQL-SERVER >= 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET authentication_string=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
MYSQL-SERVER < 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET password=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
I faced problems with ubuntu 18.04 and mysql 5.7, this is the solution
MYSQL-SERVER >= 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET authentication_string=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
MYSQL-SERVER < 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET password=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
answered Jun 25 '18 at 12:21
Jerfeson GuerreiroJerfeson Guerreiro
342413
342413
1
Thanks, I'm also running Ubuntu 18.04 here and theMYSQL-SERVER >= 5.7
version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 '18 at 12:41
1
This is the one that worked for in Ubuntu 18.04 mysql installation.MYSQL-SERVER >= 5.7
version to be precise.
– Sathish Manohar
Feb 16 at 7:56
add a comment |
1
Thanks, I'm also running Ubuntu 18.04 here and theMYSQL-SERVER >= 5.7
version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 '18 at 12:41
1
This is the one that worked for in Ubuntu 18.04 mysql installation.MYSQL-SERVER >= 5.7
version to be precise.
– Sathish Manohar
Feb 16 at 7:56
1
1
Thanks, I'm also running Ubuntu 18.04 here and the
MYSQL-SERVER >= 5.7
version was the only thing that actually solved the problem– Miguelgraz
Jul 4 '18 at 12:41
Thanks, I'm also running Ubuntu 18.04 here and the
MYSQL-SERVER >= 5.7
version was the only thing that actually solved the problem– Miguelgraz
Jul 4 '18 at 12:41
1
1
This is the one that worked for in Ubuntu 18.04 mysql installation.
MYSQL-SERVER >= 5.7
version to be precise.– Sathish Manohar
Feb 16 at 7:56
This is the one that worked for in Ubuntu 18.04 mysql installation.
MYSQL-SERVER >= 5.7
version to be precise.– Sathish Manohar
Feb 16 at 7:56
add a comment |
If you would like to change the MySQL root password, in a terminal enter:
sudo dpkg-reconfigure mysql-server-5.5
The MySQL daemon will be stopped, and you will be prompted to enter a new password.
1
This is a much better way to do it. I was unable to run the previous commands because of some mysql error...
– Andy
Jan 28 '16 at 3:46
sudo dpkg-reconfigure mysql-server-5.7 on ubuntu 16.04
– Nick Barrett
Feb 28 '17 at 6:42
1
I ransudo dpkg-reconfigure mysql-server-5.7
on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 '18 at 22:32
If it saysmysql-server is broken or not fully installed
, one can usesudo apt purge mysql*
andsudo apt install mysql-server
– Pavel
Oct 22 '18 at 7:30
add a comment |
If you would like to change the MySQL root password, in a terminal enter:
sudo dpkg-reconfigure mysql-server-5.5
The MySQL daemon will be stopped, and you will be prompted to enter a new password.
1
This is a much better way to do it. I was unable to run the previous commands because of some mysql error...
– Andy
Jan 28 '16 at 3:46
sudo dpkg-reconfigure mysql-server-5.7 on ubuntu 16.04
– Nick Barrett
Feb 28 '17 at 6:42
1
I ransudo dpkg-reconfigure mysql-server-5.7
on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 '18 at 22:32
If it saysmysql-server is broken or not fully installed
, one can usesudo apt purge mysql*
andsudo apt install mysql-server
– Pavel
Oct 22 '18 at 7:30
add a comment |
If you would like to change the MySQL root password, in a terminal enter:
sudo dpkg-reconfigure mysql-server-5.5
The MySQL daemon will be stopped, and you will be prompted to enter a new password.
If you would like to change the MySQL root password, in a terminal enter:
sudo dpkg-reconfigure mysql-server-5.5
The MySQL daemon will be stopped, and you will be prompted to enter a new password.
answered Dec 6 '15 at 10:15
user2206324user2206324
31125
31125
1
This is a much better way to do it. I was unable to run the previous commands because of some mysql error...
– Andy
Jan 28 '16 at 3:46
sudo dpkg-reconfigure mysql-server-5.7 on ubuntu 16.04
– Nick Barrett
Feb 28 '17 at 6:42
1
I ransudo dpkg-reconfigure mysql-server-5.7
on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 '18 at 22:32
If it saysmysql-server is broken or not fully installed
, one can usesudo apt purge mysql*
andsudo apt install mysql-server
– Pavel
Oct 22 '18 at 7:30
add a comment |
1
This is a much better way to do it. I was unable to run the previous commands because of some mysql error...
– Andy
Jan 28 '16 at 3:46
sudo dpkg-reconfigure mysql-server-5.7 on ubuntu 16.04
– Nick Barrett
Feb 28 '17 at 6:42
1
I ransudo dpkg-reconfigure mysql-server-5.7
on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 '18 at 22:32
If it saysmysql-server is broken or not fully installed
, one can usesudo apt purge mysql*
andsudo apt install mysql-server
– Pavel
Oct 22 '18 at 7:30
1
1
This is a much better way to do it. I was unable to run the previous commands because of some mysql error...
– Andy
Jan 28 '16 at 3:46
This is a much better way to do it. I was unable to run the previous commands because of some mysql error...
– Andy
Jan 28 '16 at 3:46
sudo dpkg-reconfigure mysql-server-5.7 on ubuntu 16.04
– Nick Barrett
Feb 28 '17 at 6:42
sudo dpkg-reconfigure mysql-server-5.7 on ubuntu 16.04
– Nick Barrett
Feb 28 '17 at 6:42
1
1
I ran
sudo dpkg-reconfigure mysql-server-5.7
on Ubuntu 16.04, it didn't prompt to enter a new password.– Franck Dernoncourt
Jan 22 '18 at 22:32
I ran
sudo dpkg-reconfigure mysql-server-5.7
on Ubuntu 16.04, it didn't prompt to enter a new password.– Franck Dernoncourt
Jan 22 '18 at 22:32
If it says
mysql-server is broken or not fully installed
, one can use sudo apt purge mysql*
and sudo apt install mysql-server
– Pavel
Oct 22 '18 at 7:30
If it says
mysql-server is broken or not fully installed
, one can use sudo apt purge mysql*
and sudo apt install mysql-server
– Pavel
Oct 22 '18 at 7:30
add a comment |
This works like charm I did it for Ubuntu 16.04.
Full credit to below link as I got it from there.
[https://coderwall.com/p/j9btlg/reset-the-mysql-5-7-root-password-in-ubuntu-16-04-lts][1]
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Log in without a password.
mysql -uroot mysql
Update the password for the root user.
make sure at atleast root account gets updated by the below query.
make some selection and check the existing values if you like
UPDATE mysql.user SET
authentication_string=PASSWORD('YOURNEWPASSWORD'),
plugin='mysql_native_password' WHERE User='root';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
add a comment |
This works like charm I did it for Ubuntu 16.04.
Full credit to below link as I got it from there.
[https://coderwall.com/p/j9btlg/reset-the-mysql-5-7-root-password-in-ubuntu-16-04-lts][1]
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Log in without a password.
mysql -uroot mysql
Update the password for the root user.
make sure at atleast root account gets updated by the below query.
make some selection and check the existing values if you like
UPDATE mysql.user SET
authentication_string=PASSWORD('YOURNEWPASSWORD'),
plugin='mysql_native_password' WHERE User='root';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
add a comment |
This works like charm I did it for Ubuntu 16.04.
Full credit to below link as I got it from there.
[https://coderwall.com/p/j9btlg/reset-the-mysql-5-7-root-password-in-ubuntu-16-04-lts][1]
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Log in without a password.
mysql -uroot mysql
Update the password for the root user.
make sure at atleast root account gets updated by the below query.
make some selection and check the existing values if you like
UPDATE mysql.user SET
authentication_string=PASSWORD('YOURNEWPASSWORD'),
plugin='mysql_native_password' WHERE User='root';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
This works like charm I did it for Ubuntu 16.04.
Full credit to below link as I got it from there.
[https://coderwall.com/p/j9btlg/reset-the-mysql-5-7-root-password-in-ubuntu-16-04-lts][1]
Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Log in without a password.
mysql -uroot mysql
Update the password for the root user.
make sure at atleast root account gets updated by the below query.
make some selection and check the existing values if you like
UPDATE mysql.user SET
authentication_string=PASSWORD('YOURNEWPASSWORD'),
plugin='mysql_native_password' WHERE User='root';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
edited Jan 8 at 11:55
Imran Zahoor
1,10911522
1,10911522
answered Sep 20 '17 at 19:39
lizardlizard
11615
11615
add a comment |
add a comment |
Stop MySQL
sudo service mysql stopMake MySQL service directory.
sudo mkdir /var/run/mysqldGive MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqldStart MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
5.Log in without a password.
mysql -uroot mysql
6.Update the password for the root user.
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdownStart the MySQL service normally.
sudo service mysql start
1
Hi, this answer works for me, but I had to use another command:UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
withoutAND Host='%'
. Thanks!
– David Corral
May 22 '18 at 17:51
add a comment |
Stop MySQL
sudo service mysql stopMake MySQL service directory.
sudo mkdir /var/run/mysqldGive MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqldStart MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
5.Log in without a password.
mysql -uroot mysql
6.Update the password for the root user.
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdownStart the MySQL service normally.
sudo service mysql start
1
Hi, this answer works for me, but I had to use another command:UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
withoutAND Host='%'
. Thanks!
– David Corral
May 22 '18 at 17:51
add a comment |
Stop MySQL
sudo service mysql stopMake MySQL service directory.
sudo mkdir /var/run/mysqldGive MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqldStart MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
5.Log in without a password.
mysql -uroot mysql
6.Update the password for the root user.
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdownStart the MySQL service normally.
sudo service mysql start
Stop MySQL
sudo service mysql stopMake MySQL service directory.
sudo mkdir /var/run/mysqldGive MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqldStart MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
5.Log in without a password.
mysql -uroot mysql
6.Update the password for the root user.
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdownStart the MySQL service normally.
sudo service mysql start
answered Apr 2 '18 at 11:11
Rahul RaveendranRahul Raveendran
8111
8111
1
Hi, this answer works for me, but I had to use another command:UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
withoutAND Host='%'
. Thanks!
– David Corral
May 22 '18 at 17:51
add a comment |
1
Hi, this answer works for me, but I had to use another command:UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
withoutAND Host='%'
. Thanks!
– David Corral
May 22 '18 at 17:51
1
1
Hi, this answer works for me, but I had to use another command:
UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
without AND Host='%'
. Thanks!– David Corral
May 22 '18 at 17:51
Hi, this answer works for me, but I had to use another command:
UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
without AND Host='%'
. Thanks!– David Corral
May 22 '18 at 17:51
add a comment |
This solution belongs to the previous version of MySQL.
By logging in to MySQL using socket authentication, you can do it.
sudo mysql -u root
Then the following command could be run.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Details are available here .
1
I couldn't login assudo mysql -u root
but I was able to do it assudo mysql
and run theALTER USER
command.
– itsols
Oct 24 '18 at 7:59
add a comment |
This solution belongs to the previous version of MySQL.
By logging in to MySQL using socket authentication, you can do it.
sudo mysql -u root
Then the following command could be run.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Details are available here .
1
I couldn't login assudo mysql -u root
but I was able to do it assudo mysql
and run theALTER USER
command.
– itsols
Oct 24 '18 at 7:59
add a comment |
This solution belongs to the previous version of MySQL.
By logging in to MySQL using socket authentication, you can do it.
sudo mysql -u root
Then the following command could be run.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Details are available here .
This solution belongs to the previous version of MySQL.
By logging in to MySQL using socket authentication, you can do it.
sudo mysql -u root
Then the following command could be run.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Details are available here .
answered Jul 20 '18 at 14:26
HuseyinHuseyin
91721931
91721931
1
I couldn't login assudo mysql -u root
but I was able to do it assudo mysql
and run theALTER USER
command.
– itsols
Oct 24 '18 at 7:59
add a comment |
1
I couldn't login assudo mysql -u root
but I was able to do it assudo mysql
and run theALTER USER
command.
– itsols
Oct 24 '18 at 7:59
1
1
I couldn't login as
sudo mysql -u root
but I was able to do it as sudo mysql
and run the ALTER USER
command.– itsols
Oct 24 '18 at 7:59
I couldn't login as
sudo mysql -u root
but I was able to do it as sudo mysql
and run the ALTER USER
command.– itsols
Oct 24 '18 at 7:59
add a comment |
Echoing rogerdpack's comment: if you don't know the MySQL root password and you don't care about MySQL data/settings, you can reinstall it and reset the root's password as follows:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo rm -rf /var/lib/mysql
sudo apt-get install -y mysql-server mysql-client
During the installation, you can choose the root's password:
2
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 '18 at 23:23
add a comment |
Echoing rogerdpack's comment: if you don't know the MySQL root password and you don't care about MySQL data/settings, you can reinstall it and reset the root's password as follows:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo rm -rf /var/lib/mysql
sudo apt-get install -y mysql-server mysql-client
During the installation, you can choose the root's password:
2
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 '18 at 23:23
add a comment |
Echoing rogerdpack's comment: if you don't know the MySQL root password and you don't care about MySQL data/settings, you can reinstall it and reset the root's password as follows:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo rm -rf /var/lib/mysql
sudo apt-get install -y mysql-server mysql-client
During the installation, you can choose the root's password:
Echoing rogerdpack's comment: if you don't know the MySQL root password and you don't care about MySQL data/settings, you can reinstall it and reset the root's password as follows:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo rm -rf /var/lib/mysql
sudo apt-get install -y mysql-server mysql-client
During the installation, you can choose the root's password:
edited Jan 27 '18 at 1:36
answered Jan 22 '18 at 22:39
Franck DernoncourtFranck Dernoncourt
37.8k32196344
37.8k32196344
2
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 '18 at 23:23
add a comment |
2
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 '18 at 23:23
2
2
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 '18 at 23:23
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 '18 at 23:23
add a comment |
This is the solution for me. I work at Ubuntu 18.04:
https://stackoverflow.com/a/46076838/2400373
But is important this change in the last step:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
add a comment |
This is the solution for me. I work at Ubuntu 18.04:
https://stackoverflow.com/a/46076838/2400373
But is important this change in the last step:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
add a comment |
This is the solution for me. I work at Ubuntu 18.04:
https://stackoverflow.com/a/46076838/2400373
But is important this change in the last step:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
This is the solution for me. I work at Ubuntu 18.04:
https://stackoverflow.com/a/46076838/2400373
But is important this change in the last step:
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
answered Nov 20 '18 at 3:22
juanitourquizajuanitourquiza
425818
425818
add a comment |
add a comment |
If you know your current password, you don't have to stop mysql server.
Open the ubuntu terminal.
Login to mysql using:
mysql - username -p
Then type your password.
This will take you into the mysql console.
Inside the console, type:
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Then flush privileges using:
> flush privileges;
Then you are all done.
add a comment |
If you know your current password, you don't have to stop mysql server.
Open the ubuntu terminal.
Login to mysql using:
mysql - username -p
Then type your password.
This will take you into the mysql console.
Inside the console, type:
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Then flush privileges using:
> flush privileges;
Then you are all done.
add a comment |
If you know your current password, you don't have to stop mysql server.
Open the ubuntu terminal.
Login to mysql using:
mysql - username -p
Then type your password.
This will take you into the mysql console.
Inside the console, type:
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Then flush privileges using:
> flush privileges;
Then you are all done.
If you know your current password, you don't have to stop mysql server.
Open the ubuntu terminal.
Login to mysql using:
mysql - username -p
Then type your password.
This will take you into the mysql console.
Inside the console, type:
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Then flush privileges using:
> flush privileges;
Then you are all done.
answered Aug 24 '17 at 7:38
Peter MutisyaPeter Mutisya
12123
12123
add a comment |
add a comment |
When you use MySQL's PASSWORD()
on the system where you want to change the password, it can cause the password turn up in a MySQL log in cleartext [source]. Keeping them, their backups etc. as secure as the password sounds like nightmare to me, so I rather like to do it as follows:
On your local machine, run this with your password:
mysql -u someuser -p < <(echo "SELECT PASSWORD('mypass');")
Note the space in front to prevent it from turning up in the bash history (for other distros than Ubuntu, this might work differently – source).
On your server machine, execute the following command to change its MySQL root password (replace
myhash
with your password's hash as printed by the first command):
mysql -u root -p < <(echo "SET PASSWORD FOR root@localhost = 'myhash';")
Optionally, let's be a bit paranoid: On your local machine, clear your terminal screen with
clear
and purge your virtual terminal scrollback, to hide the cleartext password appearing in the command above.
add a comment |
When you use MySQL's PASSWORD()
on the system where you want to change the password, it can cause the password turn up in a MySQL log in cleartext [source]. Keeping them, their backups etc. as secure as the password sounds like nightmare to me, so I rather like to do it as follows:
On your local machine, run this with your password:
mysql -u someuser -p < <(echo "SELECT PASSWORD('mypass');")
Note the space in front to prevent it from turning up in the bash history (for other distros than Ubuntu, this might work differently – source).
On your server machine, execute the following command to change its MySQL root password (replace
myhash
with your password's hash as printed by the first command):
mysql -u root -p < <(echo "SET PASSWORD FOR root@localhost = 'myhash';")
Optionally, let's be a bit paranoid: On your local machine, clear your terminal screen with
clear
and purge your virtual terminal scrollback, to hide the cleartext password appearing in the command above.
add a comment |
When you use MySQL's PASSWORD()
on the system where you want to change the password, it can cause the password turn up in a MySQL log in cleartext [source]. Keeping them, their backups etc. as secure as the password sounds like nightmare to me, so I rather like to do it as follows:
On your local machine, run this with your password:
mysql -u someuser -p < <(echo "SELECT PASSWORD('mypass');")
Note the space in front to prevent it from turning up in the bash history (for other distros than Ubuntu, this might work differently – source).
On your server machine, execute the following command to change its MySQL root password (replace
myhash
with your password's hash as printed by the first command):
mysql -u root -p < <(echo "SET PASSWORD FOR root@localhost = 'myhash';")
Optionally, let's be a bit paranoid: On your local machine, clear your terminal screen with
clear
and purge your virtual terminal scrollback, to hide the cleartext password appearing in the command above.
When you use MySQL's PASSWORD()
on the system where you want to change the password, it can cause the password turn up in a MySQL log in cleartext [source]. Keeping them, their backups etc. as secure as the password sounds like nightmare to me, so I rather like to do it as follows:
On your local machine, run this with your password:
mysql -u someuser -p < <(echo "SELECT PASSWORD('mypass');")
Note the space in front to prevent it from turning up in the bash history (for other distros than Ubuntu, this might work differently – source).
On your server machine, execute the following command to change its MySQL root password (replace
myhash
with your password's hash as printed by the first command):
mysql -u root -p < <(echo "SET PASSWORD FOR root@localhost = 'myhash';")
Optionally, let's be a bit paranoid: On your local machine, clear your terminal screen with
clear
and purge your virtual terminal scrollback, to hide the cleartext password appearing in the command above.
edited Apr 13 '17 at 12:36
Community♦
11
11
answered Mar 6 '14 at 17:48
taniustanius
3,32411926
3,32411926
add a comment |
add a comment |
To update the "root" Mysql user password you must have in mind that you will need of super user permissions for that. If you have super user privilegies, try the following commands:
MySQL 5.7.6 and later
sudo su
service mysql stop
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
q;
exit
mysql -u root -p MyNewPass
MySQL 5.7.5 and earlier
sudo su
service mysql stop
mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
q;
exit
mysql -u root -p MyNewPass
add a comment |
To update the "root" Mysql user password you must have in mind that you will need of super user permissions for that. If you have super user privilegies, try the following commands:
MySQL 5.7.6 and later
sudo su
service mysql stop
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
q;
exit
mysql -u root -p MyNewPass
MySQL 5.7.5 and earlier
sudo su
service mysql stop
mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
q;
exit
mysql -u root -p MyNewPass
add a comment |
To update the "root" Mysql user password you must have in mind that you will need of super user permissions for that. If you have super user privilegies, try the following commands:
MySQL 5.7.6 and later
sudo su
service mysql stop
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
q;
exit
mysql -u root -p MyNewPass
MySQL 5.7.5 and earlier
sudo su
service mysql stop
mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
q;
exit
mysql -u root -p MyNewPass
To update the "root" Mysql user password you must have in mind that you will need of super user permissions for that. If you have super user privilegies, try the following commands:
MySQL 5.7.6 and later
sudo su
service mysql stop
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
q;
exit
mysql -u root -p MyNewPass
MySQL 5.7.5 and earlier
sudo su
service mysql stop
mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
q;
exit
mysql -u root -p MyNewPass
answered Feb 7 '18 at 13:56
alvaropacoalvaropaco
750917
750917
add a comment |
add a comment |
Instead of resetting the password there is a work around on the local machine if you have setup phpmyadmin
to connect without giving the password or username. Check this out by starting mysql
, apache
etc. I have xampp
installed in my local machine. So starting the xampp will start all the necessary services. Now going to http://localhost/phpmyadmin
shows me all the databases. This confirms that you have saved the username and passsword in the config file of phpmyadmin which can be found in the phpmyadmin
install location. If you have xampp
installed the phpmyadmin
folder can be found in the root folder of xampp
installation. Search for the word password
in the config.inc.php
file. There you will find the password
and username
.
add a comment |
Instead of resetting the password there is a work around on the local machine if you have setup phpmyadmin
to connect without giving the password or username. Check this out by starting mysql
, apache
etc. I have xampp
installed in my local machine. So starting the xampp will start all the necessary services. Now going to http://localhost/phpmyadmin
shows me all the databases. This confirms that you have saved the username and passsword in the config file of phpmyadmin which can be found in the phpmyadmin
install location. If you have xampp
installed the phpmyadmin
folder can be found in the root folder of xampp
installation. Search for the word password
in the config.inc.php
file. There you will find the password
and username
.
add a comment |
Instead of resetting the password there is a work around on the local machine if you have setup phpmyadmin
to connect without giving the password or username. Check this out by starting mysql
, apache
etc. I have xampp
installed in my local machine. So starting the xampp will start all the necessary services. Now going to http://localhost/phpmyadmin
shows me all the databases. This confirms that you have saved the username and passsword in the config file of phpmyadmin which can be found in the phpmyadmin
install location. If you have xampp
installed the phpmyadmin
folder can be found in the root folder of xampp
installation. Search for the word password
in the config.inc.php
file. There you will find the password
and username
.
Instead of resetting the password there is a work around on the local machine if you have setup phpmyadmin
to connect without giving the password or username. Check this out by starting mysql
, apache
etc. I have xampp
installed in my local machine. So starting the xampp will start all the necessary services. Now going to http://localhost/phpmyadmin
shows me all the databases. This confirms that you have saved the username and passsword in the config file of phpmyadmin which can be found in the phpmyadmin
install location. If you have xampp
installed the phpmyadmin
folder can be found in the root folder of xampp
installation. Search for the word password
in the config.inc.php
file. There you will find the password
and username
.
answered Feb 25 '16 at 17:13
josephjoseph
339211
339211
add a comment |
add a comment |
You can easily change the mysql password if deployed on xampp through provided phpadmin gui.
phpMyAdmin -> User Accounts -> Edit Privileges (Select the intended user) -> Change Password (Tab)
add a comment |
You can easily change the mysql password if deployed on xampp through provided phpadmin gui.
phpMyAdmin -> User Accounts -> Edit Privileges (Select the intended user) -> Change Password (Tab)
add a comment |
You can easily change the mysql password if deployed on xampp through provided phpadmin gui.
phpMyAdmin -> User Accounts -> Edit Privileges (Select the intended user) -> Change Password (Tab)
You can easily change the mysql password if deployed on xampp through provided phpadmin gui.
phpMyAdmin -> User Accounts -> Edit Privileges (Select the intended user) -> Change Password (Tab)
answered Dec 21 '16 at 4:41
Mohd ArshilMohd Arshil
105119
105119
add a comment |
add a comment |
You can use this command :
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
after that pleas use flush
FLUSH PRIVILEGES;
add a comment |
You can use this command :
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
after that pleas use flush
FLUSH PRIVILEGES;
add a comment |
You can use this command :
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
after that pleas use flush
FLUSH PRIVILEGES;
You can use this command :
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
after that pleas use flush
FLUSH PRIVILEGES;
answered Jan 2 '17 at 9:40
Rahul KarandeRahul Karande
22529
22529
add a comment |
add a comment |
for mysql 5.6 this command works and you can set password through the wizard:
sudo dpkg-reconfigure mysql-server-5.6
I tried but its not working.. I am getting this bellow error.. could you please help? This installation of MySQL is already upgraded to 5.7.21, use --force if you still need to run mysql_upgrade
– Vijaysinh Parmar
Mar 23 '18 at 7:30
add a comment |
for mysql 5.6 this command works and you can set password through the wizard:
sudo dpkg-reconfigure mysql-server-5.6
I tried but its not working.. I am getting this bellow error.. could you please help? This installation of MySQL is already upgraded to 5.7.21, use --force if you still need to run mysql_upgrade
– Vijaysinh Parmar
Mar 23 '18 at 7:30
add a comment |
for mysql 5.6 this command works and you can set password through the wizard:
sudo dpkg-reconfigure mysql-server-5.6
for mysql 5.6 this command works and you can set password through the wizard:
sudo dpkg-reconfigure mysql-server-5.6
answered May 9 '17 at 6:13
MSSMSS
1,8861421
1,8861421
I tried but its not working.. I am getting this bellow error.. could you please help? This installation of MySQL is already upgraded to 5.7.21, use --force if you still need to run mysql_upgrade
– Vijaysinh Parmar
Mar 23 '18 at 7:30
add a comment |
I tried but its not working.. I am getting this bellow error.. could you please help? This installation of MySQL is already upgraded to 5.7.21, use --force if you still need to run mysql_upgrade
– Vijaysinh Parmar
Mar 23 '18 at 7:30
I tried but its not working.. I am getting this bellow error.. could you please help? This installation of MySQL is already upgraded to 5.7.21, use --force if you still need to run mysql_upgrade
– Vijaysinh Parmar
Mar 23 '18 at 7:30
I tried but its not working.. I am getting this bellow error.. could you please help? This installation of MySQL is already upgraded to 5.7.21, use --force if you still need to run mysql_upgrade
– Vijaysinh Parmar
Mar 23 '18 at 7:30
add a comment |
You don't need all this. Simply log in:
mysql -u root -p
Then change the current user's password as the mysql>
prompt:
mysql> set password=password('the_new_password');
mysql> flush privileges;
add a comment |
You don't need all this. Simply log in:
mysql -u root -p
Then change the current user's password as the mysql>
prompt:
mysql> set password=password('the_new_password');
mysql> flush privileges;
add a comment |
You don't need all this. Simply log in:
mysql -u root -p
Then change the current user's password as the mysql>
prompt:
mysql> set password=password('the_new_password');
mysql> flush privileges;
You don't need all this. Simply log in:
mysql -u root -p
Then change the current user's password as the mysql>
prompt:
mysql> set password=password('the_new_password');
mysql> flush privileges;
answered Mar 11 '18 at 18:09
mprivatmprivat
18k44157
18k44157
add a comment |
add a comment |
You can try these some steps to reset mysql 5.7 root password :
Stop Mysql Service 1st
sudo /etc/init.d/mysql stop
Login as root without password
sudo mysqld_safe --skip-grant-tables
&
After login mysql terminal you should need execute commands more:
use mysql;
UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
flush privileges;
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
After you restart your mysql server
If you still facing error you must visit :
Reset MySQL 5.7 root password Ubuntu 16.04
add a comment |
You can try these some steps to reset mysql 5.7 root password :
Stop Mysql Service 1st
sudo /etc/init.d/mysql stop
Login as root without password
sudo mysqld_safe --skip-grant-tables
&
After login mysql terminal you should need execute commands more:
use mysql;
UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
flush privileges;
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
After you restart your mysql server
If you still facing error you must visit :
Reset MySQL 5.7 root password Ubuntu 16.04
add a comment |
You can try these some steps to reset mysql 5.7 root password :
Stop Mysql Service 1st
sudo /etc/init.d/mysql stop
Login as root without password
sudo mysqld_safe --skip-grant-tables
&
After login mysql terminal you should need execute commands more:
use mysql;
UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
flush privileges;
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
After you restart your mysql server
If you still facing error you must visit :
Reset MySQL 5.7 root password Ubuntu 16.04
You can try these some steps to reset mysql 5.7 root password :
Stop Mysql Service 1st
sudo /etc/init.d/mysql stop
Login as root without password
sudo mysqld_safe --skip-grant-tables
&
After login mysql terminal you should need execute commands more:
use mysql;
UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
flush privileges;
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
After you restart your mysql server
If you still facing error you must visit :
Reset MySQL 5.7 root password Ubuntu 16.04
edited Mar 21 '18 at 9:06
Amitesh Kumar
2,1361733
2,1361733
answered Mar 21 '18 at 8:27
Inderpal SinghInderpal Singh
9111
9111
add a comment |
add a comment |
when changing/resetting the MySQL password the following commands listed above did not help. I found that going into the terminal and using these commands is pointless. instead use the command sudo stop everything. DELETE SYSTEM 32 for windows if that helps.
1
The question is aboutubuntu
OS not windows. What do you mean by DELETE SYSTEM 32 for windows?
– EhsanT
Jan 14 '17 at 2:13
add a comment |
when changing/resetting the MySQL password the following commands listed above did not help. I found that going into the terminal and using these commands is pointless. instead use the command sudo stop everything. DELETE SYSTEM 32 for windows if that helps.
1
The question is aboutubuntu
OS not windows. What do you mean by DELETE SYSTEM 32 for windows?
– EhsanT
Jan 14 '17 at 2:13
add a comment |
when changing/resetting the MySQL password the following commands listed above did not help. I found that going into the terminal and using these commands is pointless. instead use the command sudo stop everything. DELETE SYSTEM 32 for windows if that helps.
when changing/resetting the MySQL password the following commands listed above did not help. I found that going into the terminal and using these commands is pointless. instead use the command sudo stop everything. DELETE SYSTEM 32 for windows if that helps.
answered Jan 14 '17 at 2:08
RockRock
19
19
1
The question is aboutubuntu
OS not windows. What do you mean by DELETE SYSTEM 32 for windows?
– EhsanT
Jan 14 '17 at 2:13
add a comment |
1
The question is aboutubuntu
OS not windows. What do you mean by DELETE SYSTEM 32 for windows?
– EhsanT
Jan 14 '17 at 2:13
1
1
The question is about
ubuntu
OS not windows. What do you mean by DELETE SYSTEM 32 for windows?– EhsanT
Jan 14 '17 at 2:13
The question is about
ubuntu
OS not windows. What do you mean by DELETE SYSTEM 32 for windows?– EhsanT
Jan 14 '17 at 2:13
add a comment |
To reset or change the password enter sudo dpkg-reconfigure mysql-server-X.X
(X.X is mysql version you have installed i.e. 5.6, 5.7) and then you will prompt a screen where you have to set the new password and then in next step confirm the password and just wait for a moment. That's it.
add a comment |
To reset or change the password enter sudo dpkg-reconfigure mysql-server-X.X
(X.X is mysql version you have installed i.e. 5.6, 5.7) and then you will prompt a screen where you have to set the new password and then in next step confirm the password and just wait for a moment. That's it.
add a comment |
To reset or change the password enter sudo dpkg-reconfigure mysql-server-X.X
(X.X is mysql version you have installed i.e. 5.6, 5.7) and then you will prompt a screen where you have to set the new password and then in next step confirm the password and just wait for a moment. That's it.
To reset or change the password enter sudo dpkg-reconfigure mysql-server-X.X
(X.X is mysql version you have installed i.e. 5.6, 5.7) and then you will prompt a screen where you have to set the new password and then in next step confirm the password and just wait for a moment. That's it.
answered Jan 22 '18 at 11:23
Gaurav PaliwalGaurav Paliwal
751720
751720
add a comment |
add a comment |
I had to go this route on Ubuntu 16.04.1 LTS. It is somewhat of a mix of some of the other answers above - but none of them helped. I spent an hour or more trying all other suggestions from MySql website to everything on SO, I finally got it working with:
Note: while it showed Enter password for user root, I didnt have the original password so I just entered the same password to be used as the new password.
Note: there was no /var/log/mysqld.log only /var/log/mysql/error.log
Also note this did not work for me:
sudo dpkg-reconfigure mysql-server-5.7
Nor did:
sudo dpkg-reconfigure --force mysql-server-5.5
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Then:
- kill the current mysqld pid
- run mysqld with sudo /usr/sbin/mysqld &
run /usr/bin/mysql_secure_installation
Output from mysql_secure_installation
root@myServer:~# /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: no
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Dropping test database...
Success.Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
add a comment |
I had to go this route on Ubuntu 16.04.1 LTS. It is somewhat of a mix of some of the other answers above - but none of them helped. I spent an hour or more trying all other suggestions from MySql website to everything on SO, I finally got it working with:
Note: while it showed Enter password for user root, I didnt have the original password so I just entered the same password to be used as the new password.
Note: there was no /var/log/mysqld.log only /var/log/mysql/error.log
Also note this did not work for me:
sudo dpkg-reconfigure mysql-server-5.7
Nor did:
sudo dpkg-reconfigure --force mysql-server-5.5
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Then:
- kill the current mysqld pid
- run mysqld with sudo /usr/sbin/mysqld &
run /usr/bin/mysql_secure_installation
Output from mysql_secure_installation
root@myServer:~# /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: no
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Dropping test database...
Success.Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
add a comment |
I had to go this route on Ubuntu 16.04.1 LTS. It is somewhat of a mix of some of the other answers above - but none of them helped. I spent an hour or more trying all other suggestions from MySql website to everything on SO, I finally got it working with:
Note: while it showed Enter password for user root, I didnt have the original password so I just entered the same password to be used as the new password.
Note: there was no /var/log/mysqld.log only /var/log/mysql/error.log
Also note this did not work for me:
sudo dpkg-reconfigure mysql-server-5.7
Nor did:
sudo dpkg-reconfigure --force mysql-server-5.5
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Then:
- kill the current mysqld pid
- run mysqld with sudo /usr/sbin/mysqld &
run /usr/bin/mysql_secure_installation
Output from mysql_secure_installation
root@myServer:~# /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: no
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Dropping test database...
Success.Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
I had to go this route on Ubuntu 16.04.1 LTS. It is somewhat of a mix of some of the other answers above - but none of them helped. I spent an hour or more trying all other suggestions from MySql website to everything on SO, I finally got it working with:
Note: while it showed Enter password for user root, I didnt have the original password so I just entered the same password to be used as the new password.
Note: there was no /var/log/mysqld.log only /var/log/mysql/error.log
Also note this did not work for me:
sudo dpkg-reconfigure mysql-server-5.7
Nor did:
sudo dpkg-reconfigure --force mysql-server-5.5
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Then:
- kill the current mysqld pid
- run mysqld with sudo /usr/sbin/mysqld &
run /usr/bin/mysql_secure_installation
Output from mysql_secure_installation
root@myServer:~# /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: no
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Dropping test database...
Success.Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
answered Feb 4 '18 at 0:13
JGlassJGlass
9872720
9872720
add a comment |
add a comment |
As mysql documentation on the password() function says:
This function was removed in MySQL 8.0.11.
This invalidates pretty much all existing answers for mysql v8.0.11 and newer.
Per mysql documentation the new generic way to reset the root password is as follows:
The preceding sections provide password-resetting instructions
specifically for Windows and Unix and Unix-like systems.
Alternatively, on any platform, you can reset the password using the
mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the
--skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management
statements such as ALTER USER and SET PASSWORD. Because this is
insecure, if the server is started with the --skip-grant-tables
option, it enables --skip-networking automatically to prevent remote
connections.
Connect to the MySQL server using the mysql client; no password is
necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.
To change the password for a root account with a different host name
part, modify the instructions to use that host name.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
You should now be able to connect to the MySQL server as root using the
new password. Stop the server and restart it normally (without the
--skip-grant-tables and --skip-networking options).
add a comment |
As mysql documentation on the password() function says:
This function was removed in MySQL 8.0.11.
This invalidates pretty much all existing answers for mysql v8.0.11 and newer.
Per mysql documentation the new generic way to reset the root password is as follows:
The preceding sections provide password-resetting instructions
specifically for Windows and Unix and Unix-like systems.
Alternatively, on any platform, you can reset the password using the
mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the
--skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management
statements such as ALTER USER and SET PASSWORD. Because this is
insecure, if the server is started with the --skip-grant-tables
option, it enables --skip-networking automatically to prevent remote
connections.
Connect to the MySQL server using the mysql client; no password is
necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.
To change the password for a root account with a different host name
part, modify the instructions to use that host name.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
You should now be able to connect to the MySQL server as root using the
new password. Stop the server and restart it normally (without the
--skip-grant-tables and --skip-networking options).
add a comment |
As mysql documentation on the password() function says:
This function was removed in MySQL 8.0.11.
This invalidates pretty much all existing answers for mysql v8.0.11 and newer.
Per mysql documentation the new generic way to reset the root password is as follows:
The preceding sections provide password-resetting instructions
specifically for Windows and Unix and Unix-like systems.
Alternatively, on any platform, you can reset the password using the
mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the
--skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management
statements such as ALTER USER and SET PASSWORD. Because this is
insecure, if the server is started with the --skip-grant-tables
option, it enables --skip-networking automatically to prevent remote
connections.
Connect to the MySQL server using the mysql client; no password is
necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.
To change the password for a root account with a different host name
part, modify the instructions to use that host name.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
You should now be able to connect to the MySQL server as root using the
new password. Stop the server and restart it normally (without the
--skip-grant-tables and --skip-networking options).
As mysql documentation on the password() function says:
This function was removed in MySQL 8.0.11.
This invalidates pretty much all existing answers for mysql v8.0.11 and newer.
Per mysql documentation the new generic way to reset the root password is as follows:
The preceding sections provide password-resetting instructions
specifically for Windows and Unix and Unix-like systems.
Alternatively, on any platform, you can reset the password using the
mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the
--skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management
statements such as ALTER USER and SET PASSWORD. Because this is
insecure, if the server is started with the --skip-grant-tables
option, it enables --skip-networking automatically to prevent remote
connections.
Connect to the MySQL server using the mysql client; no password is
necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.
To change the password for a root account with a different host name
part, modify the instructions to use that host name.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
You should now be able to connect to the MySQL server as root using the
new password. Stop the server and restart it normally (without the
--skip-grant-tables and --skip-networking options).
answered Oct 28 '18 at 10:52
ShadowShadow
25.9k92844
25.9k92844
add a comment |
add a comment |
Change the MySQL root password. In Simpler way
All these commands should be run as root.
Login through MySQL command line tool using your old password:
Step-1
mysql -uroot -p"your_old_password"
Then run below command:
Step-2
SET PASSWORD FOR root@'localhost' = PASSWORD('your_new_password');
Method-2 (First login using your old password using above command)
Run this command, which sets a password for the current user:
SET PASSWORD = PASSWORD('your_new_password');
Above command is for the current user. If you want to change the password for other user, you can put the user name instead of "root".
add a comment |
Change the MySQL root password. In Simpler way
All these commands should be run as root.
Login through MySQL command line tool using your old password:
Step-1
mysql -uroot -p"your_old_password"
Then run below command:
Step-2
SET PASSWORD FOR root@'localhost' = PASSWORD('your_new_password');
Method-2 (First login using your old password using above command)
Run this command, which sets a password for the current user:
SET PASSWORD = PASSWORD('your_new_password');
Above command is for the current user. If you want to change the password for other user, you can put the user name instead of "root".
add a comment |
Change the MySQL root password. In Simpler way
All these commands should be run as root.
Login through MySQL command line tool using your old password:
Step-1
mysql -uroot -p"your_old_password"
Then run below command:
Step-2
SET PASSWORD FOR root@'localhost' = PASSWORD('your_new_password');
Method-2 (First login using your old password using above command)
Run this command, which sets a password for the current user:
SET PASSWORD = PASSWORD('your_new_password');
Above command is for the current user. If you want to change the password for other user, you can put the user name instead of "root".
Change the MySQL root password. In Simpler way
All these commands should be run as root.
Login through MySQL command line tool using your old password:
Step-1
mysql -uroot -p"your_old_password"
Then run below command:
Step-2
SET PASSWORD FOR root@'localhost' = PASSWORD('your_new_password');
Method-2 (First login using your old password using above command)
Run this command, which sets a password for the current user:
SET PASSWORD = PASSWORD('your_new_password');
Above command is for the current user. If you want to change the password for other user, you can put the user name instead of "root".
answered Feb 16 at 12:11
PyDevSRSPyDevSRS
838614
838614
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f16556497%2fhow-to-reset-or-change-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
If you don't need the data you can "reset" the password by removing mysql in its entirety: stackoverflow.com/questions/10853004/… then installing it again (it will prompt you for the "new" root password) FWIW :)
– rogerdpack
Jan 12 '18 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 '18 at 22:29
1
in mysql-server-5.7 these methods dont work. use 'sudo' without password as mentioned in askubuntu.com/a/848504
– Pragalathan M
May 13 '18 at 14:37