Login to the server that has access to the MariaDB database you want to use. Often this is the same machine that is hosting the database, sometimes it isn't.

To connect to the database type:

mysql -u username -p -h host databasename

Replace username with your database username, host with the URI of the database server (if the database is on the local host you can enter 'localhost'), and databasename with the name of the database you want to access. When prompted to enter your password, enter it.

If the copy of MariaDB that you want to access is on the same machine as you, you can ignore the "-h host" argument. The mysql program will assume that you are logging in to a local database.

If your mysql username is the same as your computer login name, you can leave the "-u username" argument off.

If your login is successful you should see something that looks similar to this:

daniel@mycomputer:~$ mysql -u daniel -p -h localhost test
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.2.0-MariaDB-beta Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [test]>

The 'MariaDB [test]>' prompt is what we are interested in. The is where you will enter in all of your SQL statements. More about those on the next page in the primer. For now, let me explain the parts of the prompt:

  1. The "MariaDB" part tells you that you are connected to a MariaDB database.
  2. The word between the brackets ('[' and ']') is the name of the database you are connected to. In the example above we are connected to the 'test' database.
  3. The '>' is the final bit of the prompt. It exists to tell you that the program is ready and waiting for you to enter in your commands.

Previous: A MariaDB Primer 01 - Intro
Next: A MariaDB Primer 03 - Viewing

Comments

Comments loading...