[英]Access denied for user 'root'@'localhost' (using password: NO) for MySQL 8.0+
Initially mysql -u root
was working fine.最初
mysql -u root
工作正常。
Then I tried to reset root
user password using below command然后我尝试使用以下命令重置
root
用户密码
UPDATE set authentication_string=PASSWORD("password") where User='root';
But when I tried mysql -u root -ppassword
it's throwing但是当我尝试
mysql -u root -ppassword
它抛出
access denied for user 'root'@'localhost' (using password: NO)
So to fix above solution do following steps:因此,要修复上述解决方案,请执行以下步骤:
which mysql
which mysql
/usr/local/bin/mysql
/usr/local/bin/mysql
cd /usr/local/bin
cd /usr/local/bin
mysql.server
file and execute mysql.server stop
mysql.server
文件并执行mysql.server stop
output is:
output 是:
Shutting down MySQL关机 MySQL
.. SUCCESS!
成功!
killall mysqld mysqld_safe
killall mysqld mysqld_safe
mysqld_safe --skip-grant-tables &
mysqld_safe --skip-grant-tables &
mysql -u root
it will workmysql -u root
它会工作So next step is to update the root password back to <no-password>
所以下一步是将root密码更新回
<no-password>
use mysql;
use mysql;
Update user set authentication_string='' where User='root';
Update user set authentication_string='' where User='root';
NOTE: To update mysql 8.0+ password, always use注意:要更新 mysql 8.0+ 密码,请始终使用
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.