Password settings, database and table access permissions --grant command
Use the grant command to set passwords and database and table permissions for users.
You can give one user all privileges and one user only select privileges. Create a user should be done in advance.
You can also set permissions for all tables in this database.
The syntax of the grant command.
grant permission type on database name. table name to'username' @'hostname' identified by'password';
Privilege types include "all" that grants all privileges including alter table, "insert" that grants only insert privileges, "update" that grants only update privileges, "delte" that grants only delete privileges, and select privileges only. For example, "select" to give.
Privilege types can be specified in parallel using ","
The database name and table name can use the wildcard "*" which means all.
The user name, host name, and password are strings.
For the host name, specify "%" when accessing only locally, and specify the "ip address" of that remote when accessing from a specific remote. You can use the string "%" to specify all local and remote access. In general, access control is done using a firewall instead of mariadb's function, so "%" is fine.
Give all privileges
Grant all permissions to all tables in a particular database.
grant all on my database. * to'kimotoall'@'%' identified by'eifjutab &';
Allow insert, update, delete, select for application
Give insert, update, delete, select permissions to all tables in a particular database.
grant insert, update, delete, select on mydatabase. * to'kimotoapp' @'%' identified by'eifjutab &';
Allow only select for reference
Give select permission to all tables in a particular database.
grant select on mydatabase. * to'kimotoselect' @'%' identified by'eifjutab &';