Create a database user in MariaDB

One user per application, with only the rights it needs.

SNP 140 #925 Filed sql mariadb

sql
CREATE DATABASE shop CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'shop'@'localhost' IDENTIFIED BY 'a-long-random-password';
GRANT ALL PRIVILEGES ON shop.* TO 'shop'@'localhost';
FLUSH PRIVILEGES;

'shop'@'localhost' can only connect from the same machine. For an app on another server use its IP, or '%' for anywhere (and then make sure the firewall does its job).

A read-only user for reports:

sql
CREATE USER 'reports'@'%' IDENTIFIED BY 'another-password';
GRANT SELECT ON shop.* TO 'reports'@'%';

Check what a user can do with SHOW GRANTS FOR 'shop'@'localhost';. And utf8mb4 is the one that stores emoji; plain utf8 doesn't.