> For the complete documentation index, see [llms.txt](https://dev-notes.vinguyen.blog/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-notes.vinguyen.blog/notes/deployment-and-operation/database/mysql/mysql-create-user-and-grant-permission-on-a-database.md).

# Mysql - Create user & grant permission on a database

```sql
CREATE USER 'your_username'@'%' IDENTIFIED BY 'your_password';// Some code

CREATE DATABASE `your_database_name`;

// Grant all permission
GRANT ALL PRIVILEGES ON `your_database_name`.* TO 'your_username'@'%';

// Grant readonly permission
GRANT SELECT, UPDATE, DELETE, INSERT ON `your_database_name`.* TO 'your_username'@'%';

```
