Yesterday Everything was working fine. Today when i start mysql its start giving me following error message
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
I don't know when and how it sets password.
Now i am trying to set password, but its not updating it.
I am using following steps to recover password.
Stop Mysql Service
Write this in cmd:
C:\Program Files\MySQL\MySQL Server 5.5>mysqld.exe
--defaults-file="my.ini" --init-file="d:\mysql-init.txt" --console
It start showing me progress but stop responding after this message
160504 18:01:54 [Note] Server socket created on IP: '0.0.0.0'.
160504 18:01:54 [Note] Event Scheduler: Loaded 0 events
160504 18:01:54 [Note] mysqld.exe: ready for connections.
Version: '5.5.38' socket: '' port: 3306 MySQL Community Server (GPL)
I waited for more than 10 minutes but its not showing any progress after this..
Kindly guide me how to resolve this problem.
Thanks
Stop the mysql service
Edit the my.ini file or my.cnf file
Find the [mysqld] section in the ini file and add this line directly after the section [mysqld]
skip-grant-tables
Restart the mysql service.
Open the MySQL console
Now we are going to reset the password for the root user, of course this could be used to reset any users password.
Enter the following 2 commands at the mysql> command prompt, each with a semi colon at the end of a line, and press ENTER after each line to issue the command to mysql.
Pre MYSQL version 5.7
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
Post MYSQL version 5.7 the column name changed
UPDATE mysql.user SET authentication_string=PASSWORD('MyNewPass') WHERE User='root';
ALTER USER 'root'#'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
Note that the update may report that it has updated more than one row, that because there are actually 3 user accounts with the userid of 'root' each with a different domain i.e. 127.0.0.1, localhost and ::1
Now enter quit at the mysql command prompt to exit mysql.
Stop the mysql service
Edit the my.ini file or my.cnf file
Find the {mysqld] section in the ini file and Remove the skip-grant-tables parameter we added earlier.
DO NOT Leave this parameter in the ini file its a HUGH security hole.
Restart the mysql service.
You should now be able to login with phpmyadmin using the userid 'root' and the new password you have just set for that user.
Follow step-by-step to change mySQL root password.
1) Log on to server as Administrator.
2) Stop the MySQL service or kill it [mysqld-nt.exe] from Task manager [if not worked from services.msc].
3) Create a text file containing the following statements:
UPDATE mysql.user SET Password=PASSWORD('test#123') WHERE User='root';
FLUSH PRIVILEGES;
4) Save the file. For this example, the file will be named C:\mysql-init.txt.
5) Get to the command prompt: Start the MySQL server with --init-file option.
6) C:> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt
Stop mysql service
/etc/init.d/mysql stop
Skip mysql privilegies
/usr/bin/mysqld_safe --user=mysql --skip-grant-tables
Open cmd and write
mysql
Now let's use our database with this command:
use MY_DATABASE_NAME;
Update field password of the root user with the next command:
UPDATE user SET Password=PASSWORD('ourpassword') WHERE user='root';
Exit command.
exit
Initiate a new database session.
mysql -u root -p
Related
I have installed phpmyadmin on ubuntu ec2 instance. Phpmyadmin page is showing up in front page, but I am receiving error denying access to the root user. I had already set up password for the root during installation, but when I try to login using mysql -u root -p then I am getting error access denied for user 'root#localhost' (using password: YES). How can I setup root password so that I can login into phpmyadmin?
You can change the password of the root user as follows:
1.- Stop the Mysql service
service mysqld stop
O well:
/etc/init.d/mysqld stop
2.- Start the MySQL service in open mode with the following command:
mysqld_safe --skip-grant-tables --skip-networking &
3.- Once MySQL is started, you must access it with the user “root”. For this you can do it simply with:
mysql -u root
4.- Once inside MySQL, you will have to access the MySQL database, which is where you will have to change the password:
mysql> use MySQL;
5.- Within the MySQL database, you can launch the following query that will make the password change:
mysql> UPDATE user SET password = PASSWORD ('password') WHERE user = 'root';
6.- And when it finishes you will be able to leave the MySQL server with:
mysql> exit
7.- Finally you will have to restart the MySQL service so that it starts in normal mode:
service mysqld restart
O well:
/etc/init.d/mysqld restart
After completing the previous steps, you will have already modified the password of the MySQL “root” user.
I have a little problem with my phpmyadmin, in fact I accidentally delete multiple user accounts.
Since it is impossible to connect without the error:
# 1045 - Access denied for user 'root' # 'localhost' (using password: NO)
I have search a little on the net before, and even the technic:
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
does not work, or I didn't understood how it worked.
I'm on FreeBSD 8.1, my version of PhpMyadmin is 2.11.
Thank you in advance for your answers.
I summarised my solution here: http://snippets.dzone.com/posts/show/13267
sudo stop mysql
sudo mysqld --skip-grant-tables --skip-networking
mysql
mysql> update mysql.user set password = password('your_new_password') where user = 'root';
mysql> flush privileges;
mysql> exit;
sudo mysqladmin shutdown
sudo start mysql
For mysql 5.7.16 or later I found this (from mysql.com) to be the working solution. Below are some points which are different compared to previous older versions
1) I used the below command to run mysql in safe mode as per some other references which actually worked fine for me (mysql 5.7.16 ubuntu 16.04).
mysqld_safe --skip-grant-tables --skip-networking
2) The below update stmt is NOT working for later version (ie. 5.7 and above)
-- NOT Working for 5.7 and later
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
INSTEAD use below for 5.7.6 and later
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
OR user below for 5.7.5 or earlier versions.
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
I am Using MySQL Server 8 and this is how I solved this problem.
create a file and name it accordingly. I've named it as reset.txt. put below content in the file but change MyNewPass. This will be your new SQL password
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
Stop my SQL server (Go to services and search MYSQL and right-click on it and stop )
Now open a cmd in your bin folder of My SQLserver directory. in my case it's
C:\Program Files\MySQL\MySQL Server 8.0\bin
execute the following command.
mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file="C:\reset.txt'
NOTE: my reset.txt file is in the c drive. Give the correct path. Check my.ini file is in the directory. In my case, it is in
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
Finally, restart the SQL Server. Check with your new password.
Please follow the instruction from the below link to reset your root password.You have to do it from outside mysql.
Resetting MySql Password
Forgetting your MySQL password can be a real headache for you.Here are some easy steps that you can follow to recover MySql password under Windows
Stop MySql
You have to stop MySql service before you proceed.In Windows environment, go to 'Task Manager' and Under 'Service' tab find MySQL and stop it.
Write Sql to change your password
All you need to do is to create a text file and put the below two lines into that. UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; Save it under C:\ drive and give it a name 'mysql-init.txt'
Time to restart MySQL by your own.
Now it's time to restart your MySQl which you stopped in before but this time from command line. C:> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt
Finishing up!
Now you can log in with your new password. When you finish remove the file that you created in the previous stage.
Also there is a link (http://kaziprogrammingblog.osinweb.com/article/showarticle/Resetting-MySql-Password) where I have explained the same thing.
Hope this will help..:)
Answer for XAMPP on Windows:
Edit C:\xampp\mysql\bin\my.ini and insert skip-grant-tables below [mysqld]
Restart MySQL from Control Panel interface
In the phpMyAdmin window, select SQL tab from the top panel. This will open the SQL tab where we can run the SQL queries. Now type the following query in the text area and click Go
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
Remove the skip-grant-tables in the my.ini file
Restart MySQL from Control Panel interface
DONE!
Be awared that mysql root user password does not have to be the same as password for phpmyadmin.
here is what I did and it worked:
After you install (rpm installation), do a vi /etc/my.cnf.
This will give you a path where your datadir is set. For me it was datadir=/var/lib/mysql.
Add a line there user=root, and remove all the content inside the datadir path: rm -rf /var/lib/mysql/*.
Now hit the command: mysqld --initialize.
A temporary password is generated at a location. For this:
grep "A temporary password" /var/log/*.
You will get a line that says:
/var/log/mysqld.log:2018-05-01T15:13:47.937449Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root#localhost: &uosjoGfi9:K. So for me &uosjoGfi9:K was my temporary password.
Now do a mysql -u root -p. Paste your temporary password from what you got from above.
You will be in your mysql cli mode. Now do:
mysql> use mysql;
You will be asked to reset your password:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Run your ALTER command:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPswd';
And you are done.
in my case its a frustrating Windows Server installation (iis/php/mysql) so this is what i did:
PART 1: remove the old MYSQL :
NOTE: if you already have data you should back it up!
Step 1
Uninstall MySQL from Control Panel. (you should know how to do this)
Step 2
Run Command Prompt as Admini and execute the following commands to stop and remove MySQL service.
Net stop MySQL
Sc delete MySQL
Step 3
Delete these folders:
C:\Program Files\MySQL
C:\Program Files (x86)\MySQL
C:\ProgramData\MySQL
And if it exists:
C:\Users\[User-Name]\AppData\Roaming\MySQL
PART 2: Install MYSQL
Download installer from https://dev.mysql.com/downloads/installer/ and install
-MySQL Server 8.0.23
open cmd as admin and go to
c:\Program Files\MySQL\MySQL Server 8.0\bin\
run
mysqld --initialize --console
mysqld --install
now start the service (type services.msc in run panel)
now back to console run:
mysql -u root -p
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
that's it
mysql80:
update user SET authentication_string='your password after encode to sha256' where User='root';
I have been trying to reset the root password of MySQL.
I have used to two methods to reset. But I didnt get it.
Following steps are done, But it doesn't work for me:
METHOD-1:
1) Stopped running of MySQL services and created a mysql-init.txt file.
mysql-init.txt contains:
USE mysql;
UPDATE mysql.user SET Password=PASSWORD('vikash') WHERE User = 'root';
FLUSH PRIVILEGES;
2) I have opened the command prompt and i typed the following:
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqld.exe --defaults-file="my.ini" --init-file="C:\\Users\\user-name\\Desktop\\mysql-init.txt" --console
The ERROR which i got is as follows:
Could not open required defaults file: C:\Program Files\MySQL\MySQL Server 5.6\b
in\my.ini
Fatal error in defaults handling. Program aborted
METHOD-2:
I simply opened the command prompt and typed as follows:
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqladmin -uroot -psample password
vikash
I got the error as:
Warning: Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: YES)'
Please help me to reset the password...
Below is the process to reset the root user password, when we forgot the root user password or missed to recollect the password provided during installation.
OS - Ubuntu 16.04
MySQL - 5.7
Stop Mysql Server
sudo /etc/init.d/mysql stop
To avoid the error, mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists , run below commands:
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
Start mysql in safe mode:
sudo mysqld_safe --skip-grant-tables &
Login to Mysql and change the password to say 'root123':
In 5.7 version the password column is renamed as authentication_string.
mysql -uroot
mysql>use mysql;
mysql>update user set authentication_string=password('root123') where user='root';
If you get the error :: MySQL fails on: mysql “ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded” then run below commands and then run 4th Step.
mysql>update user set plugin="mysql_native_password" where User='root';
mysql>flush privileges;
quit;
Stop and Start mysql server
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Login with the new password
mysql -uroot -proot123
PFB, the URLs for reference.
https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/
mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists
MySQL user DB does not have password columns - Installing MySQL on OSX
MySQL fails on: mysql "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded"
Try stopping mysql service
/etc/init.d/mysqld stop
Run the safe executable skipping grants
mysqld_safe --skip-grant-tables &
(the trailing ampersand gets you back to the command line)
Then connect as root without password
mysql -uroot
You'll be in the mysql prompt where you can update root's password.
EDIT: I just saw you're using windows. Ok, then your first method should almost work. Instead of "UPDATE mysql.user" the file should read
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('vikash');
Then run
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqld.exe --init-file=C:\Users\user-name\Desktop\mysql-init.txt
I'm curious about the executable though... all those blank spaces can probably get windows confused. Perhaps it would be easier to create your init file in the same folder as the executable so you just have to run
mysqld.exe --init-file=mysql-init.txt
There might be other executables in there. mysqld-nt, mysqld-safe, etc. If mysqld doesn't work, try the others too.
I have installed MySQL server 5 on redhat linux. I can't login as root so I can't change the root password.
mysql -u root -p
Enter password: <blank>
ERROR 1045 (28000): Access denied for user 'root'#'localhost'
(using password: NO)
When I try to set one like this:
mysqladmin -u root password 'newpass'
I get an error:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost'
(using password: NO)'
As if there is a root password set.
I have also tried resetting the password using (described here)
/sbin/service mysqld start --skip-grant-tables
And then making:
mysql> UPDATE mysql.user SET Password=PASSWORD('newpass')
-> WHERE User='root';
ERROR 1142 (42000): UPDATE command denied to user ''#'localhost' for table 'user'
I even uninstalled mysql-server (using yum) and then reinstalled it but that did not help.
How do I force reset the root password?
One option is to save UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='root'; into a file and then manually start mysqld with --init-file=FILENAME. Once the server starts, it should reset your password, and then you should be able to log in. After this, you should shut down the server and start it normally.
A little late to the game, but I had the same issue on a raspberry pi install and found out that it needs elevation. Adding a sudo to the front of the password change allowed it to work.
sudo mysqladmin -u root password 'newpass'
followed by an elevated sql access
sudo mysql -u root -p
If either are not run as sudo, it will fail.
The root user password is an empty string by default.
And (using password: NO) says that there is no password.
Do you try to login from another system? I imagine you can only login as root user locally.
I removed the MySQL installation and deleted the data files, and then reinstalled it.
Then I was able to set the root password. Once you set the root password to something. mysqladmin won't let you reset it if you don't know it.
To reset it, you've got to have ownership over how mysqld is executed, and feed it an init file to change the root password:
https://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
This helped me on Windows with MySQL Server 5.6. Make sure you change the mysqld path to point to where you have installed MySql Server, for me it was "C:\Program Files\mysql\MySQL Server 5.6\bin\mysqld.exe":
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is
running as a Windows service, go to the Services manager:
From the Start menu, select Control Panel, then
Administrative Tools, then Services. Find the MySQL
service in the list and stop it.
If your server is not running as a service, you may need to use
the Task Manager to force it to stop.
Create a text file containing the following statements.
Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
Write the UPDATE and FLUSH statements each on a single line. The UPDATE statement resets the password for all root accounts, and the FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.
Save the file. For this example, the file will be named C:\mysql-init.txt.
Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:\> C:\mysql\bin\mysqld --init-file=C:\\mysql-init.txt
If you installed MySQL to a location other than C:\mysql, adjust the command accordingly.
The server executes the contents of the file named by the --init-file option at startup, changing each root account password.
You can also add the --console option to the command if you want server output to appear in the console window rather than in a log file.
If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option:
C:\> "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld.exe"
--defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.5\\my.ini"
--init-file=C:\\mysql-init.txt
The appropriate --defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.
After the server has started successfully, delete C:\mysql-init.txt.
http://docs.oracle.com/cd/E17952_01/refman-5.5-en/resetting-permissions.html
Remove the -p from your command. -p forces the prompt for password.
Use :
mysql -u root
This will resolve your problem.
Probably a bit late here , but here is what I did :
create file resetpass.sh which has :
UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
# mysqld_safe --init-file=resetpass.sh
# service mysqld start --skip-grant-tables
# mysql -u root -p
Enter pass
mysql > change root pass ; flush privs;
quit
# restart mysql service
The MySQL version I was using was 5.1.73 under centos6
Try do this:
mysql -u root
and then:
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES;
Worked fine for me!
According to the docs, in MySQL 5.7 the temp password gets put in /var/log/mysqld, but this is evidently not the case in 5.6.
With MySQL version 5.6 installed on RHEL 6.7, I finally found the temporary root password set during install was placed in the file /root/.mysql_secret.
open mysql
now enter the following commands :
use mysql;
update user set PASSWORD=password("updated password") where User='root';
flush privileges;
I have a little problem with my phpmyadmin, in fact I accidentally delete multiple user accounts.
Since it is impossible to connect without the error:
# 1045 - Access denied for user 'root' # 'localhost' (using password: NO)
I have search a little on the net before, and even the technic:
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
does not work, or I didn't understood how it worked.
I'm on FreeBSD 8.1, my version of PhpMyadmin is 2.11.
Thank you in advance for your answers.
I summarised my solution here: http://snippets.dzone.com/posts/show/13267
sudo stop mysql
sudo mysqld --skip-grant-tables --skip-networking
mysql
mysql> update mysql.user set password = password('your_new_password') where user = 'root';
mysql> flush privileges;
mysql> exit;
sudo mysqladmin shutdown
sudo start mysql
For mysql 5.7.16 or later I found this (from mysql.com) to be the working solution. Below are some points which are different compared to previous older versions
1) I used the below command to run mysql in safe mode as per some other references which actually worked fine for me (mysql 5.7.16 ubuntu 16.04).
mysqld_safe --skip-grant-tables --skip-networking
2) The below update stmt is NOT working for later version (ie. 5.7 and above)
-- NOT Working for 5.7 and later
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
INSTEAD use below for 5.7.6 and later
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
OR user below for 5.7.5 or earlier versions.
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
I am Using MySQL Server 8 and this is how I solved this problem.
create a file and name it accordingly. I've named it as reset.txt. put below content in the file but change MyNewPass. This will be your new SQL password
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
Stop my SQL server (Go to services and search MYSQL and right-click on it and stop )
Now open a cmd in your bin folder of My SQLserver directory. in my case it's
C:\Program Files\MySQL\MySQL Server 8.0\bin
execute the following command.
mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file="C:\reset.txt'
NOTE: my reset.txt file is in the c drive. Give the correct path. Check my.ini file is in the directory. In my case, it is in
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
Finally, restart the SQL Server. Check with your new password.
Please follow the instruction from the below link to reset your root password.You have to do it from outside mysql.
Resetting MySql Password
Forgetting your MySQL password can be a real headache for you.Here are some easy steps that you can follow to recover MySql password under Windows
Stop MySql
You have to stop MySql service before you proceed.In Windows environment, go to 'Task Manager' and Under 'Service' tab find MySQL and stop it.
Write Sql to change your password
All you need to do is to create a text file and put the below two lines into that. UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; Save it under C:\ drive and give it a name 'mysql-init.txt'
Time to restart MySQL by your own.
Now it's time to restart your MySQl which you stopped in before but this time from command line. C:> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt
Finishing up!
Now you can log in with your new password. When you finish remove the file that you created in the previous stage.
Also there is a link (http://kaziprogrammingblog.osinweb.com/article/showarticle/Resetting-MySql-Password) where I have explained the same thing.
Hope this will help..:)
Answer for XAMPP on Windows:
Edit C:\xampp\mysql\bin\my.ini and insert skip-grant-tables below [mysqld]
Restart MySQL from Control Panel interface
In the phpMyAdmin window, select SQL tab from the top panel. This will open the SQL tab where we can run the SQL queries. Now type the following query in the text area and click Go
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
Remove the skip-grant-tables in the my.ini file
Restart MySQL from Control Panel interface
DONE!
Be awared that mysql root user password does not have to be the same as password for phpmyadmin.
here is what I did and it worked:
After you install (rpm installation), do a vi /etc/my.cnf.
This will give you a path where your datadir is set. For me it was datadir=/var/lib/mysql.
Add a line there user=root, and remove all the content inside the datadir path: rm -rf /var/lib/mysql/*.
Now hit the command: mysqld --initialize.
A temporary password is generated at a location. For this:
grep "A temporary password" /var/log/*.
You will get a line that says:
/var/log/mysqld.log:2018-05-01T15:13:47.937449Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root#localhost: &uosjoGfi9:K. So for me &uosjoGfi9:K was my temporary password.
Now do a mysql -u root -p. Paste your temporary password from what you got from above.
You will be in your mysql cli mode. Now do:
mysql> use mysql;
You will be asked to reset your password:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Run your ALTER command:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPswd';
And you are done.
in my case its a frustrating Windows Server installation (iis/php/mysql) so this is what i did:
PART 1: remove the old MYSQL :
NOTE: if you already have data you should back it up!
Step 1
Uninstall MySQL from Control Panel. (you should know how to do this)
Step 2
Run Command Prompt as Admini and execute the following commands to stop and remove MySQL service.
Net stop MySQL
Sc delete MySQL
Step 3
Delete these folders:
C:\Program Files\MySQL
C:\Program Files (x86)\MySQL
C:\ProgramData\MySQL
And if it exists:
C:\Users\[User-Name]\AppData\Roaming\MySQL
PART 2: Install MYSQL
Download installer from https://dev.mysql.com/downloads/installer/ and install
-MySQL Server 8.0.23
open cmd as admin and go to
c:\Program Files\MySQL\MySQL Server 8.0\bin\
run
mysqld --initialize --console
mysqld --install
now start the service (type services.msc in run panel)
now back to console run:
mysql -u root -p
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
that's it
mysql80:
update user SET authentication_string='your password after encode to sha256' where User='root';