How to connect to MariaDB server using mysql command line option on a Unix/Linux server

Fig.05: Connecting to the server using mysql client

Fig.05: Connecting to the server using mysql client

The syntax is as follows to connect to the MariaDB server using mysql Unix or Linux or OS X client:

# connect with user and pass #
mysql -u userNameHere -p
# connect with mysql db with root user and pass #
mysql -u root -p mysql
## connect to the remote mysql server hosted on vlan ## 
mysql -h IP-here -u user -p db-name-here

Sample session for root user

Type the following command:

mysql -u root -p mysql

Sample outputs:

Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.40-MariaDB-log FreeBSD Ports
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [mysql]>

You can now type commands at MariaDB [mysql]> prompt:

MariaDB [mysql]> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
3 rows in set (0.00 sec)
MariaDB [mysql]> quit;

To exit from the server type quit.

Examples and usage: How To Install MariaDB Databases on a FreeBSD v10/11 Unix Server

3 comment

    Have a question? Post it on our forum!