ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)

Try to log into the MySQL server, but it prompts the following error message:

Terminal

$ mysql 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

1. Solution – (using password: NO)

The user ‘root’ need a password to log into the MySQL server. To solve it, please provide a password with -p flag while connecting to MySQL server.


$ mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 5.7.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

2. Solution – (using password: YES)

If you hits this (using password: YES) error :


ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

This means you are provided an invalid password.

Note
Please read this Connecting to the MySQL Server

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments