Initially mysql -u root
was working fine.
Then I tried to reset root
user password using below command
UPDATE set authentication_string=PASSWORD("password") where User='root';
But when I tried mysql -u root -ppassword
it's throwing
access denied for user 'root'@'localhost' (using password: NO)
So to fix above solution do following steps:
which mysql
/usr/local/bin/mysql
cd /usr/local/bin
mysql.server
file and execute mysql.server stop
output is:
Shutting down MySQL
. SUCCESS!
killall mysqld mysqld_safe
mysqld_safe --skip-grant-tables &
mysql -u root
it will workSo next step is to update the root password back to <no-password>
use mysql;
Update user set authentication_string='' where User='root';
NOTE: To update mysql 8.0+ password, always use
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.