Mariadb is an open source database forked from another popular open source database MySQL. MariaDB developers are original developers of the MySQL. After Oracle get management of the MySQL project they become unhappy with the management of the Oracle and started MariaDB project. Latest available version for MariaDB was 10.1.18 as writing but we will get what our distribution provides us.
Install MariaDB
We will use dnf
inorder to install MariaDB. The package is called as mariadb-server
.
$ sudo dnf install mariadb-server -y
OR we can use traditional yum
package manager like below.
$ sudo yum install mariadb-server -y
Start MariaDB Database Service with systemctl
After installing the required MariaDB packages we will list current status of the MariaDB serviceor daemon with <a href="https://www.poftut.com/linux-systemctl-service-management-tutorial/" target="_blank" rel="noopener noreferrer">systemctl</a>
command like below.
$ systemctl status mariadb ● mariadb.service - MariaDB 10.1 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: inactive (dead)
It is stopped now we will start the service and look to the status again.
$ sudo systemctl start mariadb $ sudo systemctl status mariadb ● mariadb.service - MariaDB 10.1 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: active (running) since Sun 2016-10-16 02:22:27 UTC; 3s ago Process: 4775 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS) Process: 4587 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS) Process: 4551 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS) Main PID: 4746 (mysqld) Status: "Taking your SQL requests now..." Tasks: 26 (limit: 512) Memory: 191.8M CPU: 1.306s CGroup: /system.slice/mariadb.service └─4746 /usr/libexec/mysqld --basedir=/usr Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: See the MariaDB Knowledgebase at http://mariadb.com/kb or the Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: MySQL manual for more instructions. Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: Please report any problems at http://mariadb.org/jira Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: The latest information about MariaDB is available at http://mariadb.org/. Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: You can find additional information about the MySQL part at: Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: http://dev.mysql.com Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: Support MariaDB development by buying support/new features from MariaDB Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: Corporation Ab. You can contact us about this at sales@mariadb.com. Oct 16 02:22:27 poftut3 mysqld[4746]: 2016-10-16 2:22:27 140436492912832 [Note] /usr/libexec/mysqld (mysqld 10.1.18-MariaDB) startin Oct 16 02:22:27 poftut3 systemd[1]: Started MariaDB 10.1 database server.
Login To The MariaDB Console
We will login to the MariaDb Console. As stated before MariaDB forked from MySQL and most of the tools are compatible with the MySQL. We will use MySQL database management tool for this. We will provide root user and password.
$ mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 10.1.18-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)]>
Getting Help For MariaDB
By issuing help command we can list basic commands.
MariaDB [(none)]> \h General information about MariaDB can be found atMariaDB FoundationList of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents'
List Databases in MariaDB
We can use show databases;
command to list databases in MariaDB
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec)
How to Install Mariadb / Mysql Server in Linux Fedora, CentOS and RedHat? Infografic

2 thoughts on “How to Install Mariadb / Mysql Server in Linux Fedora, CentOS and RedHat?”