How to Connect to mariadb using MySQL Client

Posted on

This is an article showing how to connect to mariadb database server using MySQL client. MySQL client is actually can be utilized to connect to mariadb database server. So, in order to connect to mariadb, there are several things to be done can be done in the following steps :

  1. Install MySQL client as follows :

[root@hostname ~]# yum install mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 3:10.1.20-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 3:10.1.20-1.el7 for package: 3:mariadb-10.1.20-1.el7.x86_64
--> Processing Dependency: mariadb-common(x86-64) = 3:10.1.20-1.el7 for package: 3:mariadb-10.1.20-1.el7.x86_64
--> Running transaction check
---> Package mariadb-common.x86_64 3:10.1.17-1.el7 will be updated
---> Package mariadb-common.x86_64 3:10.1.20-1.el7 will be an update
---> Package mariadb-libs.x86_64 3:10.1.17-1.el7 will be updated
---> Package mariadb-libs.x86_64 3:10.1.20-1.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================================================================================
 Package                                             Arch                                        Version                                                Repository                                  Size
=========================================================================================================================================================================================================
Installing:
 mariadb                                             x86_64                                      3:10.1.20-1.el7                                        cloud                                      6.3 M
Updating for dependencies:
 mariadb-common                                      x86_64                                      3:10.1.20-1.el7                                        cloud                                       63 k
 mariadb-libs                                        x86_64                                      3:10.1.20-1.el7                                        cloud                                      643 k
Transaction Summary
=========================================================================================================================================================================================================
Install  1 Package
Upgrade             ( 2 Dependent packages)
Total download size: 7.0 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/3): mariadb-common-10.1.20-1.el7.x86_64.rpm                                                                                                                                    |  63 kB  00:00:00     
(2/3): mariadb-libs-10.1.20-1.el7.x86_64.rpm                                                                                                                                      | 643 kB  00:00:00     
(3/3): mariadb-10.1.20-1.el7.x86_64.rpm                                                                                                                                           | 6.3 MB  00:00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                     31 MB/s | 7.0 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 3:mariadb-common-10.1.20-1.el7.x86_64                                                                                                                                                 1/5 
  Updating   : 3:mariadb-libs-10.1.20-1.el7.x86_64                                                                                                                                                   2/5 
  Installing : 3:mariadb-10.1.20-1.el7.x86_64                                                                                                                                                        3/5 
  Cleanup    : 3:mariadb-libs-10.1.17-1.el7.x86_64                                                                                                                                                   4/5 
  Cleanup    : 3:mariadb-common-10.1.17-1.el7.x86_64                                                                                                                                                 5/5 
  Verifying  : 3:mariadb-libs-10.1.20-1.el7.x86_64                                                                                                                                                   1/5 
  Verifying  : 3:mariadb-10.1.20-1.el7.x86_64                                                                                                                                                        2/5 
  Verifying  : 3:mariadb-common-10.1.20-1.el7.x86_64                                                                                                                                                 3/5 
  Verifying  : 3:mariadb-common-10.1.17-1.el7.x86_64                                                                                                                                                 4/5 
  Verifying  : 3:mariadb-libs-10.1.17-1.el7.x86_64                                                                                                                                                   5/5 
Installed:
  mariadb.x86_64 3:10.1.20-1.el7                                                                                                                                                                         
Dependency Updated:
  mariadb-common.x86_64 3:10.1.20-1.el7                                                                mariadb-libs.x86_64 3:10.1.20-1.el7                                                               
Complete!
[root@hostname ~]# 

2. Test to connect to mariadb using mysql client which has already been installed before in the previous step as shown below :

[root@hostname ~]# mysql -uroot -p -h xxx.xxx.xxx.xxx
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 151
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
5 rows in set (0,00 sec)
MariaDB [(none)]> quit
Bye
[root@hostname ~]# 

Leave a Reply