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 use the host (-h
) option.
Tip
It is possible to add the password after -p
on the command line, with a couple of caveats. First, there can't be a space between the -p and the password. For example if our username is tom and...