Databases 8 min read

Master MariaDB: Step-by-Step Installation, Core Commands, and User Management

This guide walks you through installing MariaDB via binary packages, explains its configuration file hierarchy, demonstrates essential client and server commands for data definition and manipulation, and details how to create users and manage their privileges effectively.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master MariaDB: Step-by-Step Installation, Core Commands, and User Management

1. Installation Methods and Steps

MariaDB can be installed using RPM packages, yum, binary packages, or source compilation. This tutorial follows the binary package approach.

Download and extract the desired version: tar xf mariadb-5.5.48-linux-86_64.tar.gz -C /usr/local/ Create a symbolic link, set ownership, and prepare the data directory:

cd /usr/local
ln -sv mariadb-5.5.48 mysql
chown -R root.mysql mysql
groupadd -r mysql
useradd -r -g mysql mysql
mkdir -pv /mydata/data
chown -R mysql.mysql /mydata/data

Provide configuration and startup scripts:

cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/my.server /etc/init.d/mysqld
chkconfig --add /etc/init.d/mysqld
chkconfig mysqld on

Add essential settings to /etc/my.cnf:

datadir=/mydata/data
skip-name-resolve=ON
innodb-file-per-table=ON

Initialize and start the database:

/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mydata/data
service mysqld start

Secure the installation:

mysql_secure_installation

2. MariaDB Basics

Configuration file search order: /etc/my.cnf → /etc/mysql/my.cnf → ~/.my.cnf Command‑line client options: -u username (default root) -h host (default localhost)

-p password
-D database_name

(select database) -e "SQL statement" (execute directly)

Example:

mysql -uroot -hlocalhost -p -e "show databases;"

3. Server Commands

Data Definition Language (DDL) manages database objects such as schemas, tables, indexes, views, users, and stored procedures. Common commands:

create database db_name;
alter database db_name;
drop database db_name;

Show supported character sets and collations:

show character set;
show collation;

Table operations (create, alter, drop, add column, modify column, add primary key, add index, etc.) are demonstrated with examples throughout the guide.

Data Manipulation Language (DML) handles data within tables.

Insert: insert into students (id,name) values (1,'alren'); Select: select * from students where id=1; Update: update students set age=age+10 where name like '%lren'; Delete:

delete from students where id>10;

4. Creating Users and Managing Privileges

Create a user account: create user 'username'@'host' identified by 'password'; Delete a user: DROP USER 'username'@'host'; Grant privileges:

grant ALL on db_name.* to 'username'@'host' identified by 'password';

Privilege scopes: *.* – all databases, all tables db_name.* – all tables in a specific database db_name.tbl_name – a specific table

Test the granted privileges by logging in remotely and performing allowed operations.

Revoke privileges when needed:

revoke INSERT, UPDATE on db_name.* from 'username'@'host';
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

User ManagementDDLMariaDBDMLSQL CommandsDatabase Installation
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.