> For the complete documentation index, see [llms.txt](https://kb.asyraf.my/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.asyraf.my/linux-guide/mysql-basic-management.md).

# MySQL Basic Management

This guide will show you the basic MySQL command in adding database,users with password and also assign ownership/permission for a user to a database

1. First login to your mysql database via root :

```
mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.3.13-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
```

2\. Use below commands to create database and create user that have access to the databases

```
create database [database name];
grant all on [database name].* to '[database user]'@'%' identified by '[database user password]';
flush privileges;
quit;
```

{% hint style="info" %}
please change \[database name] , \[database user] and \[database user password] accordingly to your needs
{% endhint %}

3\. Finally to test, login as the new user and use command :

```
show databases;
```

4\. It is working if the output shows the new database.
