MariaDB Commands

Enter MariaDB mysql console

sudo mysql

or below command and then root password

mysql -u root -p

List all users of a MariaDB

SELECT user FROM mysql.user;

List all databases

SHOW DATABASES;

Create new database

CREATE DATABASE databasename;

Create new user and grant access to the database

GRANT ALL ON databasename.* TO 'username'@'localhost' IDENTIFIED BY 'passoword' WITH GRANT OPTION;

Flush Privileges

FLUSH PRIVILEGES;

Delete Database

DROP DATABASE databasename;

Delete User

DROP USER username;

Exit MariaDB console

EXIT;

Last updated