Solve mariadb grant ERROR 1045 (28000): Access denied for user

Source: Internet
Author: User

I have been using mariadb for a while. The common commands and syntaxes have not changed. A little more complex, such as replication, does not find any difference in root mysql.

However, there are actually some differences today. mariadb's permission management root mysql is different. mysql can create an account with the same root account permissions, but mariadb won't work, and the writing is also different.

1. mariadb grant authorization error
  
MariaDB [(none)]> grant all privileges on *. * TO tank @ '2017. 192.% 'identified by 'test ';
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO)

The same command is run in mysql.
At first, I thought that the root account and password of mariadb were incorrect. After checking, there was no problem.

2. mariadb and mysql have different root permissions.

Check that the permissions of the root account are different from those of mysql.
  
MariaDB [(none)]> show grants \ G;
* *************************** 1. row ***************************
Grants for root @ localhost: grant select, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, show databases, SUPER, create temporary tables, lock tables, EXECUTE, replication slave, replication client, create view, show view, create routine, alter routine, create user, EVENT, trigger on *. * TO 'root' @ 'localhost' WITH GRANT OPTION
1 row in set (0.00 sec)
 
ERROR: No query specified
  
Mysql> show grants;
+ --------------------------------------------------------------------- +
| Grants for root @ localhost |
+ --------------------------------------------------------------------- +
| Grant all privileges on *. * TO 'root' @ 'localhost' with grant option |
+ --------------------------------------------------------------------- +
1 row in set (0.00 sec)

3. mariadb and mysql grant have different syntaxes.

Specific lecture to, please refer to: https://mariadb.com/kb/en/mariadb/grant/
  
MariaDB [(none)]> grant all on test. * TO tank @ '2017. 192.% 'identified by 'test ';
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [(none)]> grant select on *. * TO tank @ '2017. 192.% 'identified by 'test ';
Query OK, 0 rows affected (0.00 sec)

Run the first command to grant all permissions of the test database to tank.
The second command gives the select permission for all databases and tables to tank.
Note: all cannot be used with *. *. Otherwise, an error is returned.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.