MariaDB administration

Login to an existing installation

mysql -u USERNAME -p 

This will log in to the current local installation, to login to a remote host. MariaDB or MySQL must be installed to execute the command

mysql -u USERNAME -p PASSWORD -h HOSTNAME

Once Logged in a few useful commands to run:

  • checking the version
    SELECT VERSION()
  • Show a list of Databases
    SHOW DATABSES
  • To see a list of users
    USE msql; SELECT Host, User FROM user;
  • Add a User
  • Remove a User
  • Restrict a User
  • Create Table
    CREATE DATABASE todo;
    CREATE TABLE todo.tasks
    ( id INT(11) unsigned NOT NULL AUTO_INCREMENT
    , description VARCHAR(500) NOT NULL
    , completed BOOLEAN NOT NULL DEFAULT 0
    , PRIMARY KEY (id)
    );
  • Close, Exit, Quit
    quit