ERROR 1044 (42000): Access denied for user ‘root’@’localhost’

What are the eight life cycle hook functions of Vue>>>

Colleagues reported that a MySQL 5.6 creation user could not be authorized, and prompted [error 1044 (42000): access denied for user ‘root’ @’localhost ‘]. As follows:

mysql> grant all on xxx.* to xxx@'localhost' identified by 'xxx';
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'xxxx'
mysql> 

The root user should not have permission. Check the permissions

[root@localhost][mysql]> select current_user() from dual;
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

[root@localhost][mysql]> select host,user from user where user='root';
+-----------+------+
| host      | user |
+-----------+------+
| %         | root |
| localhost | root |
+-----------+------+
2 rows in set (0.00 sec)

[root@localhost][mysql]> show grants for root;
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@%                                                                                                              |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

It looks ok. Just look at grant_ Priv’s permission is up

[root@localhost][mysql]> SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user;
+-----------+---------+-------------------------------------------+------------+------------+
| host      | user    | password                                  | Grant_priv | Super_priv |
+-----------+---------+-------------------------------------------+------------+------------+
| %         | root    | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | N          | Y          |
+-----------+---------+-------------------------------------------+------------+------------+
1 rows in set (0.00 sec)

Find grant_ Priv permission is n, that is to say, the root user cannot authorize other users. Try y instead

[root@localhost][mysql]> UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
[root@localhost][mysql]> FLUSH PRIVILEGES;

Try adding users again, no problem

mysql>  grant all on xxx.* to xxx@'192.168.%' identified by 'test1249';
Query OK, 0 rows affected, 1 warning (0.00 sec)
 
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Similar Posts: