Creating New MariaDB Databases

From Littledamien Wiki
Revision as of 22:32, 4 March 2024 by Video8 (talk | contribs)
Jump to navigation Jump to search

Create user

MariaDB User management knowledge base. [1]

CREATE OR REPLACE USER 'user_name'@'host' IDENTIFIED BY 'password';

Host can be something like localhost or '192.123.123.%'. [2]

IP addresses need to be surrounded by quotes. Put the user name in quotes and the host in quotes, but not the @ symbol.

Ranges in the IP can be specified with the % wildcard or subnet masks, e.g. 192.123.123.0/255.255.255.0.

Password is supplied as-is. Unencrypted and not passed through the PASSWORD() function.

Create database

CREATE DATABASE IF NOT EXISTS example_database;

Grant user access to database

To grant access to all objects in the database to a user:

GRANT ALL PRIVILEDGES ON example_database.* TO 'user_name'@'192.123.123.%' IDENTIFIED BY 'my_password';

Reference