As much as I love self-hosted services, the ones with MySql/MariaDB backends always have me looking up the same old commands over and over again! I figured it might be an idea to record some of these here so I remember in the future.

Remember to add a user to a database - the amount of time you would save if you always remembered this!

Login to Mysql

mysql -u root -p

Create a database

CREATE DATABASE testdb;

Create a user

CREATE USER 'username'@'host' IDENTIFIED BY '123456';

Grant permissions to a user on a database

GRANT ALL ON database.* TO 'username'@'host';

delete a user or database

DROP USER 'username'@'host';

Show databases

SHOW DATABASES;

Show users

SELECT User, Host FROM mysql.user;

Export a database

mysqldump -u root –p testdb > testdb.sql

Saving Everything

FLUSH PRIVILIGES;