pretty simple and using the asterisk cdr database as an example …
log in to console locally or via ssh
then enter mysql/mariadb with
~]# mysql
then
MariaDB [(none)]> use mysql;
then create your user and password with the following
MariaDB [mysql]> CREATE USER ‘someuser’@‘%’ IDENTIFIED BY ‘somepassword’;
define from where the resource can connect , we’ll use anywhere
MariaDB [mysql]> grant select on asteriskcdrdb.* TO ‘someuser’@‘%’;
finally apply the new permissions with
MariaDB [mysql]> FLUSH PRIVILEGES;
you can then test with something like mysql workbench
good luck