Thursday, November 26, 2015

How do you access MariaDB in XAMPP?

We have seen that MariaDB is an off spring of MySQL and when we launch (as administrator) XAMPP from its shortcut shown here:

 
XAMPP-Maria01.png

What we see displayed is the following (it is assumed any service running is stopped and the bottom pane is cleared):
 
XAMPP-Maria01.png

Click Start for MySQL and it is already running as shown here:

 
XAMPP-Maria03.png

MySQL is running on Port 3306.
Click on Shell.

The XAMPP prompt is displayed with the following message.
---
Setting environment for using XAMPP for Windows.
Jayaram@HODENTEK8 c:\j
#

----------------
When you enter mysql as shown you get the MariaDB prompt as shown
 
XAMPP-Maria04.png

MariaDB syntax is very similar to MySQL syntax as for as its usage is concerned.
Alternately you can do the same from the install directory as shown here:
-----------
Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\Jayaram>cd\

C:\>cd C:\J\mysql\bin

C:\J\mysql\bin>dir mysql*
 Volume in drive C is TI10672700E
 Volume Serial Number is 16FB-D230

 Directory of C:\J\mysql\bin

10/14/2015  10:44 PM         3,571,528 mysql.exe
10/14/2015  10:45 PM         3,517,768 mysqladmin.exe
10/14/2015  10:45 PM         3,595,080 mysqlbinlog.exe
10/14/2015  10:44 PM         3,515,208 mysqlcheck.exe
10/14/2015  10:45 PM        11,527,496 mysqld.exe
10/14/2015  10:44 PM         3,568,456 mysqldump.exe
10/14/2015  10:16 PM             8,385 mysqldumpslow.pl
10/14/2015  10:16 PM            25,817 mysqld_multi.pl
10/14/2015  10:16 PM            36,102 mysqlhotcopy.pl
10/14/2015  10:45 PM         3,506,504 mysqlimport.exe
10/14/2015  10:45 PM         3,507,528 mysqlshow.exe
10/14/2015  10:45 PM         3,525,448 mysqlslap.exe
10/14/2015  10:44 PM         3,916,616 mysqltest.exe
10/14/2015  10:48 PM         9,949,000 mysqltest_embedded.exe
10/14/2015  10:38 PM         3,899,392 mysql_client_test.exe
10/14/2015  10:48 PM        10,124,104 mysql_client_test_embedded.exe
10/14/2015  10:16 PM             8,799 mysql_config.pl
10/14/2015  10:16 PM             4,417 mysql_convert_table_format.pl
10/14/2015  10:48 PM         9,804,104 mysql_embedded.exe
10/14/2015  10:46 PM         3,735,368 mysql_install_db.exe
10/14/2015  10:45 PM         3,119,944 mysql_plugin.exe
10/14/2015  10:16 PM             9,565 mysql_secure_installation.pl
10/14/2015  10:46 PM         3,124,040 mysql_tzinfo_to_sql.exe
10/14/2015  10:45 PM         3,178,824 mysql_upgrade.exe
10/14/2015  10:46 PM         3,109,192 mysql_upgrade_service.exe
10/14/2015  10:57 PM         1,750,344 mysql_upgrade_wizard.exe
              26 File(s)     95,639,029 bytes
               0 Dir(s)  797,801,631,744 bytes free

C:\J\mysql\bin>mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.8-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

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

----------------------------------------------------
You can also get to the administrator using the mysqladmin.exe as shown here (truncated portion):
 
XAMPP-Maria05.png

For MariaDB server find contents as shown here:

XAMPP-Maria06.png

MariaDB has good documentation. Here is the help on Utility | Use:
-----------------------------------------
MariaDB [(none)]> help Utility
You asked for help about help category: "Utility"
For more information, type 'help ', where is one of the following
topics:
   EXPLAIN
   HELP STATEMENT
   USE

MariaDB [(none)]> help USE
Name: 'USE'
Description:
Syntax:
USE db_name

The USE db_name statement tells MySQL to use the db_name database as
the default (current) database for subsequent statements. The database
remains the default until the end of the session or another USE
statement is issued:

USE db1;
SELECT COUNT(*) FROM mytable;   # selects from db1.mytable
USE db2;
SELECT COUNT(*) FROM mytable;   # selects from db2.mytable


Here are some queries run on this version:

 MariaDB Version
------------
MariaDB [(none)]> Select Version(), CURRENT_DATE;
+----------------+--------------+
| Version()      | CURRENT_DATE |
+----------------+--------------+
| 10.1.8-MariaDB | 2015-11-26   |
+----------------+--------------+
1 row in set (0.04 sec)

MariaDB [(none)]>

---------------------
 Find User interactively
---------
Find the USER() (this is interactively run)
----------------
MariaDB [(none)]> SELECT
    -> USER()
    -> ,
    -> CURRENT_DATE;
+----------------+--------------+
| USER()         | CURRENT_DATE |
+----------------+--------------+
| ODBC@localhost | 2015-11-26   |
+----------------+--------------+
1 row in set (0.00 sec)

MariaDB [(none)]>

--------------------
There are only two bases in the installation.
Show databases
-----------
MariaDB [(none)]> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.08 sec)

MariaDB [(none)]>



No comments: