In this MySql tutorial we will solve very important MySql error - How to resolve ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) / (using password: YES) in MySql.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) in MySql>
when you try to login to root user using mysql -u root. You may face ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
|
The default password for user root is blank (i.e. an empty string). If in case it has never been changed then you may simply login to root user using mysql -u root command.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) in MySql >
when you try to login to root user using mysql -u root -p, and if you enter wrong password, you may face ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p
Enter password: ***
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
|
SOLUTION to ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES/NO) in MySql>
For solving this problem, when you try to login to root user, type
mysql -u root -p. You will be asked for password and enter correct password to login.
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 45
Server version: 5.6.25-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
|
The default password for user root is blank (i.e. an empty string). If in case it has never been changed then you may simply login to root user using mysql -u root command -
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 5.6.25-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
|
How to change the MySql user(root) password in MySql
Change MySql user password 1: Changing the root password - When root password is blank (i.e. an empty string).
you can use
SET PASSWORD FOR root@localhost = PASSWORD('new-password');
to set new password.
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root
mysql> SET PASSWORD FOR root@localhost = PASSWORD('new-password');
Query OK, 0 rows affected (0.00 sec)
mysql> SET PASSWORD FOR root@127.0.0.1 = PASSWORD('new-password');
Query OK, 0 rows affected (0.00 sec)
mysql>
|
or, use
UPDATE mysql.user SET Password = PASSWORD('new-password')
WHERE User = 'root';
to set new password.
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('new-password')
-> WHERE User = 'root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql>
|
Change MySql user password 2: Changing the root password - When root password is NOT blank.
First you'll have to enter existing password for root user, than you can use
SET PASSWORD FOR root@localhost = PASSWORD('new-password');
to set new password.
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> SET PASSWORD FOR root@localhost = PASSWORD('new-password');
Query OK, 0 rows affected (0.00 sec)
mysql> SET PASSWORD FOR root@127.0.0.1 = PASSWORD('new-password');
Query OK, 0 rows affected (0.00 sec)
mysql>
|
or,
use
UPDATE mysql.user SET Password = PASSWORD('new-password')
WHERE User = 'root';
to set new password.
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> UPDATE mysql.user SET Password = PASSWORD('new-password')
-> WHERE User = 'root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql>
|
Change MySql user password 3: Changing the root password using mysqladmin.
First you'll have to enter existing password for root user, than you can enter set new password.
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqladmin -u root -p password
Enter password: ****
New password: *****
Confirm new password: *****
C:\Program Files\MySQL\MySQL Server 5.6\bin>
|
Change MySql user password 4: UBUNTU user can try this for setting up root password >
sudo dpkg-reconfigure mysql-server-5.6
|
In this MySql tutorial we solved very important MySql error - How to resolve ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) / (using password: YES) in MySql.
Related >>
How to change the MySql user(root) password tutorial
How to reset the forgotten MySql root password
Labels:
MySql
MySql errors