MariaDB Command Line Interface



index
Disabled back button Next Section
printable version

Section 0: Module Objectives or Competencies
Course Objective or Competency
The student will be able to install an RDBMS and utilize a wide range of features available in that RDBMS.
Section 1: Overview

There are various ways of interacting with MariaDB, including the command line interface, scripts, administrative tools like phpMyAdmin, and embedded SQL.

Graphically oriented MariaDB administration tools abound, but for true speed and no-frills management perhaps nothing is more effective than the command-line driven client.

Therefore we'll begin with the command line interface.

Using the command line interface also provides good training for writing embedded SQL statements as you learn to code database interfaces.

Section 2: Starting MariaDB

In order to use the MariaDB command line interface, you have to start MySQL.

  1. Open the Command Prompt.
    • If you don't know how the function keys work with the command prompt, visit this link.
  2. Type "path". If the resulting path list does not contain a path similar to "C:\Program Files\MariaDB 10.9\bin" then on the next line type "cd C:\Program Files\MariaDB 10.9\bin".
    • In order to paste into the command prompt you need to right click the command prompt and select Paste from the pop-up menu.
  3. Enter "mysql -u root -p"
    • This only works if you are logging in on the same machine on which MariaDB is running.
    • Otherwise, see this MySQL link.
  4. Enter the password (assuming you DID set up a password).

If you did everything correctly, you should see the MariaDB> prompt.

Command Line Interface 1.
Section 3: Creating and Opening a Database

If you have not yet created a database, type a data definition command as explained in the SQL notes.

CREATE DATABASE EXAMPLE1;

As noted in an earlier lecture, don't forget the semi-colon at the end of the statement.

Just because you have created a database doesn't mean that you can use it! To use it, you first enter the USE command.

USE EXAMPLE1;

To find out what databases are available, enter...

SHOW DATABASES;




This site has several arcane tips for using the command line interface.

Here are some cool tricks for manipulating the MySQL Client Command Line that will probably transfer to MariaDB as well.

Section 4: Entering SQL Commands

Now that you are "using" a database, you can enter any of the data definition, data management, and data query commands.

CREATE TABLE VENDOR (   V_CODE INTEGER NOT NULL UNIQUE,   V_NAME VARCHAR(35) NOT NULL,   V_CONTACT VARCHAR(15) NOT NULL,   V_AREACODE CHAR(3) NOT NULL,   V_PHONE CHAR(8) NOT NULL,   V_STATE CHAR(2) NOT NULL,   V_ORDER CHAR(1) NOT NULL,   PRIMARY KEY (V_CODE));

I recommend that you practice the commands that you saw in the SQL notes and figure out any differences that may be required by MariaDB.

Section 5: Resources

These are intended for MySQL, but since MariaDB is the open source version of MySQL, many of them are applicable.