1045-Access denied for user ‘root’@’localhost’解决方法

几行代码轻松解决

1.进入数据库:

mysql -u root -p  

2.输入数据库密码:

******* 

3.依次执行以下sql:

CREATE USER 'root'@'%' IDENTIFIED BY '你的密码'; 
GRANT ALL ON *.* TO 'root'@'%'; 
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
FLUSH PRIVILEGES;

4.完美解决此问题

1045-Access denied for user ‘root’@’localhost’解决方法,亲测可用插图