Hugonweb | MariaDB/MySQL Administration

SQL Prompt as a User

For a local database:

mariadb -p -u <username> <databasename>

If the server is remote, then:

mariadb -p -u <username> -h <hostname> -P <port> <databasename>

and then type in the password at the prompt.

Remember all commands end in a semicolon.

Installation

Install mariadb-server on Debian/Ubuntu

Administration

You do all user and database creation from within the database. By default, the system root user has full administration privileges. So:

$ sudo mariadb

User Creation

Then create users:

CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';

Database Creation

Create databases:

CREATE DATABASE <databasename> CHARACTER SET utf8mb4;

You want that utf8mb4. The "utf8" character set doesn't allow 4-byte characters like some emojis and math symbols!

Give a User Privileges

Give a user all privileges on a database:

GRANT ALL PRIVILEGES ON <databasename>.* TO '<username>'@'localhost';