How to reset or change the MySQL root password?
up vote
120
down vote
favorite
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 |
up vote
120
down vote
favorite
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 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 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 at 14:37
add a comment |
up vote
120
down vote
favorite
up vote
120
down vote
favorite
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,0671727
2,0671727
asked May 15 '13 at 3:47
asm234
7373915
7373915
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 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 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 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 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 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 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 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 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 at 22:29
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 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 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 at 14:37
add a comment |
26 Answers
26
active
oldest
votes
up vote
138
down vote
accepted
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
YOURNEWPASSWORDwith your new password:
UPDATE
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
passwordcolumn 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
12
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 startto 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 PASSWORDMySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
10
It doesn't work with me!
– moderns
Jul 14 '14 at 17:44
32
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
4
in some cases, you also need to runmkdir /var/run/mysqldandchown mysql: /var/run/mysqldbetween steps 1 and 2
– Neville Nazerane
Feb 2 at 2:38
|
show 8 more comments
up vote
84
down vote
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
19
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
2
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 at 6:25
|
show 1 more comment
up vote
68
down vote
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 |
up vote
65
down vote
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 restartmysql -u rootuse mysqlselect * 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;exitsudo vim /etc/mysql/my.cnfRemove 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
7
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 addusershould be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 at 2:50
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 at 2:55
add a comment |
up vote
33
down vote
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 |
up vote
27
down vote
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
5
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 at 13:16
add a comment |
up vote
12
down vote
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.7on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 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 at 7:30
add a comment |
up vote
11
down vote
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.7version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 at 12:41
1
Good thing it was helpful, share it with anyone who has the same problem.
– Jerfeson Guerreiro
Jul 5 at 0:03
So para constar acho que o root do mysql so é acessado pelo sudo. Pelo menos foi o que funcionou pra mim.
– Ismael Junior
Jul 19 at 18:52
add a comment |
up vote
9
down vote
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' AND Host='%';
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 |
up vote
8
down vote
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
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 at 17:51
add a comment |
up vote
7
down vote
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 rootbut I was able to do it assudo mysqland run theALTER USERcommand.
– itsols
Oct 24 at 7:59
1
Life savior. Quick and clean.
– Marcelo Agimóvel
Nov 4 at 0:08
add a comment |
up vote
6
down vote
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:

1
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 at 23:23
add a comment |
up vote
3
down vote
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 |
up vote
2
down vote
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
myhashwith 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
clearand purge your virtual terminal scrollback, to hide the cleartext password appearing in the command above.
add a comment |
up vote
2
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
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 at 7:30
add a comment |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
0
down vote
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 aboutubuntuOS not windows. What do you mean by DELETE SYSTEM 32 for windows?
– EhsanT
Jan 14 '17 at 2:13
add a comment |
up vote
0
down vote
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 |
up vote
0
down vote
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 |
up vote
0
down vote
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 |
26 Answers
26
active
oldest
votes
26 Answers
26
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
138
down vote
accepted
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
YOURNEWPASSWORDwith your new password:
UPDATE
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
passwordcolumn 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
12
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 startto 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 PASSWORDMySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
10
It doesn't work with me!
– moderns
Jul 14 '14 at 17:44
32
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
4
in some cases, you also need to runmkdir /var/run/mysqldandchown mysql: /var/run/mysqldbetween steps 1 and 2
– Neville Nazerane
Feb 2 at 2:38
|
show 8 more comments
up vote
138
down vote
accepted
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
YOURNEWPASSWORDwith your new password:
UPDATE
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
passwordcolumn 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
12
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 startto 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 PASSWORDMySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
10
It doesn't work with me!
– moderns
Jul 14 '14 at 17:44
32
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
4
in some cases, you also need to runmkdir /var/run/mysqldandchown mysql: /var/run/mysqldbetween steps 1 and 2
– Neville Nazerane
Feb 2 at 2:38
|
show 8 more comments
up vote
138
down vote
accepted
up vote
138
down vote
accepted
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
YOURNEWPASSWORDwith your new password:
UPDATE
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
passwordcolumn 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
YOURNEWPASSWORDwith your new password:
UPDATE
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: on some versions, if
passwordcolumn 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 at 3:09
Lemayzeur
5,1371833
5,1371833
answered May 15 '13 at 3:52
Christian Mark
5,256123374
5,256123374
12
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 startto 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 PASSWORDMySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
10
It doesn't work with me!
– moderns
Jul 14 '14 at 17:44
32
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
4
in some cases, you also need to runmkdir /var/run/mysqldandchown mysql: /var/run/mysqldbetween steps 1 and 2
– Neville Nazerane
Feb 2 at 2:38
|
show 8 more comments
12
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 startto 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 PASSWORDMySQL instruction is for you.
– tanius
Mar 6 '14 at 17:51
10
It doesn't work with me!
– moderns
Jul 14 '14 at 17:44
32
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
4
in some cases, you also need to runmkdir /var/run/mysqldandchown mysql: /var/run/mysqldbetween steps 1 and 2
– Neville Nazerane
Feb 2 at 2:38
12
12
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
10
10
It doesn't work with me!
– moderns
Jul 14 '14 at 17:44
It doesn't work with me!
– moderns
Jul 14 '14 at 17:44
32
32
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
4
4
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 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 at 2:38
|
show 8 more comments
up vote
84
down vote
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
19
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
2
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 at 6:25
|
show 1 more comment
up vote
84
down vote
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
19
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
2
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 at 6:25
|
show 1 more comment
up vote
84
down vote
up vote
84
down vote
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
user12345
1,59911617
1,59911617
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
19
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
2
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 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
19
Doesn't seem to work with 5.7 on newer ubuntu
– fuzzyTew
Dec 26 '16 at 2:15
2
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 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
19
19
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
2
2
sudo dpkg-reconfigure mysql-server-5.7 not working for Ubuntu 18.04 for reset root password. Any other alternate?
– Jagdeep Singh
May 21 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 at 6:25
|
show 1 more comment
up vote
68
down vote
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 |
up vote
68
down vote
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 |
up vote
68
down vote
up vote
68
down vote
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
Anvesh
3,24122735
3,24122735
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 |
up vote
65
down vote
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 restartmysql -u rootuse mysqlselect * 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;exitsudo vim /etc/mysql/my.cnfRemove 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
7
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 addusershould be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 at 2:50
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 at 2:55
add a comment |
up vote
65
down vote
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 restartmysql -u rootuse mysqlselect * 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;exitsudo vim /etc/mysql/my.cnfRemove 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
7
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 addusershould be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 at 2:50
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 at 2:55
add a comment |
up vote
65
down vote
up vote
65
down vote
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 restartmysql -u rootuse mysqlselect * 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;exitsudo vim /etc/mysql/my.cnfRemove 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 restartmysql -u rootuse mysqlselect * 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;exitsudo vim /etc/mysql/my.cnfRemove 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 at 13:07
Ravindra Gullapalli
7,81433161
7,81433161
answered Jul 31 '15 at 17:28
narko
1,4571624
1,4571624
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
7
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 addusershould be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 at 2:50
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 at 2:55
add a 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
7
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 addusershould be this wayselect * from mysql.user where user = 'root';
– user615274
May 17 at 2:50
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 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
7
7
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 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 at 2:50
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 at 2:55
Sad this does not work for me mysql 5.7.22 ubuntu 18.04
– user615274
May 17 at 2:55
add a comment |
up vote
33
down vote
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 |
up vote
33
down vote
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 |
up vote
33
down vote
up vote
33
down vote
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,45821735
4,45821735
answered Oct 26 '13 at 20:22
faisalbhagat
1,6341823
1,6341823
add a comment |
add a comment |
up vote
27
down vote
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
5
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 at 13:16
add a comment |
up vote
27
down vote
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
5
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 at 13:16
add a comment |
up vote
27
down vote
up vote
27
down vote
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
fabriciofreitag
1,275816
1,275816
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
5
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 at 13: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
5
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 at 13: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
5
5
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 at 13:16
Very useful ! In my specific case (Ubuntu 18.04 LTS), I had to replace the host '%' to 'localhost'
– FredericK
May 7 at 13:16
add a comment |
up vote
12
down vote
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.7on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 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 at 7:30
add a comment |
up vote
12
down vote
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.7on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 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 at 7:30
add a comment |
up vote
12
down vote
up vote
12
down vote
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
user2206324
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.7on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 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 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.7on Ubuntu 16.04, it didn't prompt to enter a new password.
– Franck Dernoncourt
Jan 22 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 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 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 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 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 at 7:30
add a comment |
up vote
11
down vote
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.7version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 at 12:41
1
Good thing it was helpful, share it with anyone who has the same problem.
– Jerfeson Guerreiro
Jul 5 at 0:03
So para constar acho que o root do mysql so é acessado pelo sudo. Pelo menos foi o que funcionou pra mim.
– Ismael Junior
Jul 19 at 18:52
add a comment |
up vote
11
down vote
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.7version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 at 12:41
1
Good thing it was helpful, share it with anyone who has the same problem.
– Jerfeson Guerreiro
Jul 5 at 0:03
So para constar acho que o root do mysql so é acessado pelo sudo. Pelo menos foi o que funcionou pra mim.
– Ismael Junior
Jul 19 at 18:52
add a comment |
up vote
11
down vote
up vote
11
down vote
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 at 12:21
Jerfeson Guerreiro
137212
137212
1
Thanks, I'm also running Ubuntu 18.04 here and theMYSQL-SERVER >= 5.7version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 at 12:41
1
Good thing it was helpful, share it with anyone who has the same problem.
– Jerfeson Guerreiro
Jul 5 at 0:03
So para constar acho que o root do mysql so é acessado pelo sudo. Pelo menos foi o que funcionou pra mim.
– Ismael Junior
Jul 19 at 18:52
add a comment |
1
Thanks, I'm also running Ubuntu 18.04 here and theMYSQL-SERVER >= 5.7version was the only thing that actually solved the problem
– Miguelgraz
Jul 4 at 12:41
1
Good thing it was helpful, share it with anyone who has the same problem.
– Jerfeson Guerreiro
Jul 5 at 0:03
So para constar acho que o root do mysql so é acessado pelo sudo. Pelo menos foi o que funcionou pra mim.
– Ismael Junior
Jul 19 at 18:52
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 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 at 12:41
1
1
Good thing it was helpful, share it with anyone who has the same problem.
– Jerfeson Guerreiro
Jul 5 at 0:03
Good thing it was helpful, share it with anyone who has the same problem.
– Jerfeson Guerreiro
Jul 5 at 0:03
So para constar acho que o root do mysql so é acessado pelo sudo. Pelo menos foi o que funcionou pra mim.
– Ismael Junior
Jul 19 at 18:52
So para constar acho que o root do mysql so é acessado pelo sudo. Pelo menos foi o que funcionou pra mim.
– Ismael Junior
Jul 19 at 18:52
add a comment |
up vote
9
down vote
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' AND Host='%';
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 |
up vote
9
down vote
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' AND Host='%';
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 |
up vote
9
down vote
up vote
9
down vote
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' AND Host='%';
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' AND Host='%';
EXIT;
Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start
edited Sep 20 '17 at 19:44
answered Sep 20 '17 at 19:39
lizard
9614
9614
add a comment |
add a comment |
up vote
8
down vote
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
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 at 17:51
add a comment |
up vote
8
down vote
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
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 at 17:51
add a comment |
up vote
8
down vote
up vote
8
down vote
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 at 11:11
Rahul Raveendran
8111
8111
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 at 17:51
add a comment |
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 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 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 at 17:51
add a comment |
up vote
7
down vote
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 rootbut I was able to do it assudo mysqland run theALTER USERcommand.
– itsols
Oct 24 at 7:59
1
Life savior. Quick and clean.
– Marcelo Agimóvel
Nov 4 at 0:08
add a comment |
up vote
7
down vote
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 rootbut I was able to do it assudo mysqland run theALTER USERcommand.
– itsols
Oct 24 at 7:59
1
Life savior. Quick and clean.
– Marcelo Agimóvel
Nov 4 at 0:08
add a comment |
up vote
7
down vote
up vote
7
down vote
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 at 14:26
Huseyin
91721931
91721931
1
I couldn't login assudo mysql -u rootbut I was able to do it assudo mysqland run theALTER USERcommand.
– itsols
Oct 24 at 7:59
1
Life savior. Quick and clean.
– Marcelo Agimóvel
Nov 4 at 0:08
add a comment |
1
I couldn't login assudo mysql -u rootbut I was able to do it assudo mysqland run theALTER USERcommand.
– itsols
Oct 24 at 7:59
1
Life savior. Quick and clean.
– Marcelo Agimóvel
Nov 4 at 0:08
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 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 at 7:59
1
1
Life savior. Quick and clean.
– Marcelo Agimóvel
Nov 4 at 0:08
Life savior. Quick and clean.
– Marcelo Agimóvel
Nov 4 at 0:08
add a comment |
up vote
6
down vote
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:

1
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 at 23:23
add a comment |
up vote
6
down vote
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:

1
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 at 23:23
add a comment |
up vote
6
down vote
up vote
6
down vote
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 at 1:36
answered Jan 22 at 22:39
Franck Dernoncourt
35.9k30191338
35.9k30191338
1
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 at 23:23
add a comment |
1
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 at 23:23
1
1
I wish I had started here instead of wasting an hour banging my head at trying to reset the password.
– Eric Seastrand
Sep 12 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 at 23:23
add a comment |
up vote
3
down vote
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 |
up vote
3
down vote
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 |
up vote
3
down vote
up vote
3
down vote
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 Mutisya
11123
11123
add a comment |
add a comment |
up vote
2
down vote
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
myhashwith 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
clearand purge your virtual terminal scrollback, to hide the cleartext password appearing in the command above.
add a comment |
up vote
2
down vote
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
myhashwith 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
clearand purge your virtual terminal scrollback, to hide the cleartext password appearing in the command above.
add a comment |
up vote
2
down vote
up vote
2
down vote
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
myhashwith 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
clearand 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
myhashwith 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
clearand 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
tanius
3,11411826
3,11411826
add a comment |
add a comment |
up vote
2
down vote
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 |
up vote
2
down vote
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 |
up vote
2
down vote
up vote
2
down vote
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 at 13:56
alvaropaco
655816
655816
add a comment |
add a comment |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
up vote
1
down vote
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
joseph
169111
169111
add a comment |
add a comment |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
up vote
1
down vote
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 Arshil
100118
100118
add a comment |
add a comment |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
up vote
1
down vote
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 Karande
22529
22529
add a comment |
add a comment |
up vote
1
down vote
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 at 7:30
add a comment |
up vote
1
down vote
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 at 7:30
add a comment |
up vote
1
down vote
up vote
1
down vote
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
MSS
1,7571321
1,7571321
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 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 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 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 at 7:30
add a comment |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
up vote
1
down vote
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 at 18:09
mprivat
17.8k44057
17.8k44057
add a comment |
add a comment |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
up vote
1
down vote
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 at 9:06
Amitesh Kumar
2,1321732
2,1321732
answered Mar 21 at 8:27
Inderpal Singh
9111
9111
add a comment |
add a comment |
up vote
1
down vote
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 |
up vote
1
down vote
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 |
up vote
1
down vote
up vote
1
down vote
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 at 3:22
juanitourquiza
357518
357518
add a comment |
add a comment |
up vote
0
down vote
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 aboutubuntuOS not windows. What do you mean by DELETE SYSTEM 32 for windows?
– EhsanT
Jan 14 '17 at 2:13
add a comment |
up vote
0
down vote
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 aboutubuntuOS not windows. What do you mean by DELETE SYSTEM 32 for windows?
– EhsanT
Jan 14 '17 at 2:13
add a comment |
up vote
0
down vote
up vote
0
down vote
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
Rock
19
19
1
The question is aboutubuntuOS 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 aboutubuntuOS 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 |
up vote
0
down vote
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 |
up vote
0
down vote
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 |
up vote
0
down vote
up vote
0
down vote
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 at 11:23
Gaurav Paliwal
675619
675619
add a comment |
add a comment |
up vote
0
down vote
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 |
up vote
0
down vote
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 |
up vote
0
down vote
up vote
0
down vote
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 at 0:13
JGlass
9492620
9492620
add a comment |
add a comment |
up vote
0
down vote
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 |
up vote
0
down vote
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 |
up vote
0
down vote
up vote
0
down vote
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 at 10:52
Shadow
25.4k92742
25.4k92742
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%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 at 22:33
Do you know the MySQL root password?
– Franck Dernoncourt
Jan 22 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 at 14:37