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.
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/localln -sv mariadb-5.5.48 mysqlchown -R root.mysql mysqlgroupadd -r mysqluseradd -r -g mysql mysqlmkdir -pv /mydata/datachown -R mysql.mysql /mydata/dataProvide configuration and startup scripts:
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnfcp /usr/local/mysql/support-files/my.server /etc/init.d/mysqldchkconfig --add /etc/init.d/mysqldchkconfig mysqld onAdd essential settings to /etc/my.cnf:
datadir=/mydata/dataskip-name-resolve=ONinnodb-file-per-table=ONInitialize and start the database:
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mydata/dataservice mysqld startSecure the installation:
mysql_secure_installation2. 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';Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
