> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/error-codes/mariadb-error-codes-1200-to-1299/e1227.md).

# Error 1227: Access denied; you need (at least one of) the privilege(s) for this operation

| Error Code | SQLSTATE | Error                               | Description                                                                      |
| ---------- | -------- | ----------------------------------- | -------------------------------------------------------------------------------- |
| 1227       | 42000    | ER\_SPECIFIC\_ACCESS\_DENIED\_ERROR | Access denied; you need (at least one of) the %s privilege(s) for this operation |

## Possible Causes and Solutions

The statement needs a global privilege that the account doesn't have. The message names the privilege, or the privileges of which any one is enough. For example:

```
SET GLOBAL max_connections=200;
ERROR 1227 (42000): Access denied; you need (at least one of) the CONNECTION ADMIN privilege(s) for this operation

SHOW BINARY LOGS;
ERROR 1227 (42000): Access denied; you need (at least one of) the BINLOG MONITOR privilege(s) for this operation

FLUSH LOGS;
ERROR 1227 (42000): Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
```

To solve the error, an administrator can [GRANT](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md) the named privilege `ON *.*`, or you can run the statement with an account that has it. Check the account's privileges with [SHOW GRANTS](/docs/server/reference/sql-statements/administrative-sql-statements/show/show-grants.md). Privileges on a database or table aren't enough, because these privileges exist only at the global level.

A common case is restoring a dump made by [mariadb-dump](/docs/server/clients-and-utilities/backup-restore-and-import-clients/mariadb-dump.md). The dump creates views, stored routines, triggers and events with a `DEFINER` clause that names the account that created them. Creating an object for a different account needs the [SET USER](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#set-user) privilege, even when you have all privileges on the database:

```
CREATE DEFINER=root@localhost VIEW v2 AS SELECT 1;
ERROR 1227 (42000): Access denied; you need (at least one of) the SET USER privilege(s) for this operation
```

To restore such a dump, do one of these:

* Restore it with an account that has the `SET USER` privilege.
* Edit the `DEFINER` clauses in the dump so that they name the account that restores it, or remove them. Without a `DEFINER` clause, the object's definer is the account that creates it.

Privileges on a database or table give different errors: [error 1044](/docs/server/reference/error-codes/mariadb-error-codes-1000-to-1099/e1044.md) for a database, and [error 1142](/docs/server/reference/error-codes/mariadb-error-codes-1100-to-1199/e1142.md) for a table.

## See Also

* [When access\_denied\_errors status variable is incremented](/docs/server/security/user-account-management/incrementing-of-the-access_denied_errors-status-variable.md)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
