Access Denied for User root@localhost
Overview
- Prerequisites
- Connect to MySQL
- Update Password
- Stop and Start MySql server
Prerequisites
- MySQL
Connect to MySql
- Execute the command below to connect to MySQL.
mysql -u root -p
- Executing the command below may result in a failure to connect to MySQL
mysql
Update Password
- Upon accessing the MySQL terminal, execute the command below to update the password of the root user.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
Stop and Start MySQL Server
sudo service mysql stop
sudo service mysql start