Connecting to MariaDB

To start the client and connect to MariaDB, we open up a command-line or terminal window and type mysql with some options and press Enter. The basic syntax is as follows:

mysql [-u <username>] [-p] [-h <host>] [<database>]

All the options in the previous syntax example are in square brackets ([]) to show that they are all optional. The parts in angle brackets (<>) are bits that we must supply if we choose to use that option. For example, if we use the -u option, we must supply a username.

Most of the time, we will use the username (-u) and password (-p) options. We will also often specify the database that we want to connect to when the client launches. When we connect remotely to a MariaDB server on another computer, we will ...

Get Getting Started with MariaDB - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.