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

When we try to login MySQL server by typing mysql, received below error message.

ERROR 1045 (28000): Access denied for user

root@ubuntu:~# mysql
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
root@ubuntu:~# mysql -u -r
ERROR 1045 (28000): Access denied for user ‘-r’@’localhost’ (using password: NO)
root@ubuntu:~#

Cause:

Current logged in user in shell or root user has password. In this case we have to provide password.

Some MySQL installations allow users to connect as the anonymous (unnamed) user to the server running on the local host. If this is the case on your machine, you should be able to connect to that server by invoking mysql without any options

Solution:

Use below command in Linux shell.

root@ubuntu:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools