Login to the server that has access to the MariaDB database server you want to use. Often this is the same machine that is hosting the server, sometimes it isn't.
To connect to MariaDB, type:
mysql -u username -p -h host databasename
- Replace username with your database username. If your database username is the same as your computer login name, you can leave the "
-u username" argument off.
- Leave out
-h hostout if the copy of MariaDB that you want to access is on the same machine as you. If not, replace host with the ip or hostname of the database server (if the server is on the local host you can also enter 'localhost).
- Replace databasename with the name of the database you want to access (such as test, which comes already created for testing purposes).
- When prompted to enter your password, enter it.
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 63 Server version: 10.1.4-MariaDB-1~trusty-wsrep-log mariadb.org binary distribution, wsrep_25.10.r4144 Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [test]>
'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:
- The "MariaDB" part tells you that you are connected to a MariaDB database server.
- 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.
'>'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.