How to install MariaDB Client on Mac, Ubuntu, CentOS, Windows
The MariaDB client is a command-line tool used to connect to and interact with MariaDB and MySQL database servers. It evolved directly from the MySQL client when MariaDB was created as a fork of MySQL. Below describe how to install it on Mac, Ubuntu, CentOS and Windows respectively.
macOS
Homebrew (Recommended)
-
Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install MariaDB client:
brew install mariadb-client
-
Add to your PATH (if needed): After installation, Homebrew may display a message asking you to add the client to your PATH. Follow the instructions shown in the terminal after installation.
Troubleshooting on macOS
-
Command not found: If the
mariadb
command isn't found after installation:brew link --force mariadb-client
Or manually add the path as shown in the installation message.
-
Connection issues: If you have problems connecting to a remote server, check your firewall settings and ensure the server allows remote connections.
Ubuntu
apt
-
Update the package index:
sudo apt update
-
Install MariaDB client only:
sudo apt install mariadb-client
MariaDB Repository (For Latest Version)
-
Import the MariaDB repository key:
sudo apt-get install software-properties-common sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
-
Add the MariaDB repository:
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirrors.xtom.com/mariadb/repo/10.6/ubuntu focal main'
Note: Replace
focal
with your Ubuntu version codename and10.6
with your desired MariaDB version. -
Update and install the client only:
sudo apt update sudo apt install mariadb-client
Troubleshooting on Ubuntu
-
Missing dependencies: If you see dependency errors:
sudo apt --fix-broken install
-
Configure client settings: Client configuration can be added in:
sudo nano /etc/mysql/mariadb.conf.d/50-mariadb-clients.cnf
CentOS
Yum
-
Create a MariaDB repository file:
sudo vi /etc/yum.repos.d/MariaDB.repo
-
Add the following content to the file:
[mariadb] name = MariaDB baseurl = https://mirrors.xtom.com/mariadb/yum/10.6/centos8-amd64 gpgkey = https://mirrors.xtom.com/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck = 1
Note: Replace
centos8-amd64
with your CentOS version and architecture, and10.6
with your desired MariaDB version. -
Install MariaDB client only:
sudo yum install MariaDB-client
Troubleshooting on CentOS
-
Repository issues: If you have problems with the repository:
sudo yum clean all sudo yum makecache
-
OpenSSL dependencies: If you encounter OpenSSL dependency problems:
sudo yum install openssl-devel
Windows
MSI
-
Download the MSI installer from the official MariaDB website.
-
Run the installer and follow these steps:
- Accept the license agreement
- Choose "Custom" installation type
- Deselect "Database instance" and keep only "Client programs" checked
- Choose installation path (default is usually fine)
- Complete the installation
Chocolatey
-
Install Chocolatey (if not already installed):
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
-
Install MariaDB client only:
choco install mariadb-cli
Troubleshooting on Windows
-
Path issues: If the 'mariadb' command isn't recognized:
- Right-click on This PC > Properties > Advanced system settings > Environment Variables
- In System Variables, find PATH, click Edit
- Add the bin directory path (e.g.,
C:\Program Files\MariaDB\bin
) - Click OK and restart Command Prompt
-
DLL errors: If you encounter missing DLL errors, try installing the Visual C++ Redistributable packages.
Verifying Your Installation
To verify your MariaDB client installation is working properly:
-
Check the client version:
mariadb --version
This should display something like:
mariadb Ver 15.1 Distrib 10.6.12-MariaDB, for OS-Type
-
Test connecting to a remote server:
mariadb -h hostname -u username -p
Replace
hostname
with your server address,username
with your database username, and enter your password when prompted.
Using the MariaDB Client
Creating a Client Configuration File
You can create a configuration file to store connection parameters:
-
Create or edit the client configuration file:
- On macOS/Linux:
~/.mariadb/mariadb.cnf
or~/.my.cnf
- On Windows:
C:\Users\YourUsername\AppData\Roaming\MariaDB\mariadb.ini
- On macOS/Linux:
-
Add your connection details:
[client] host=your_server_address user=your_username password=your_password
-
Secure the file (on Linux/macOS):
chmod 600 ~/.mariadb/mariadb.cnf
-
Connect without parameters:
mariadb
Setting Up Connection Aliases
For connecting to multiple databases easily:
-
Edit your configuration file:
[client] # Default connection [server1] host=server1.example.com user=username1 password=password1 database=database1 [server2] host=server2.example.com user=username2 password=password2 database=database2
-
Connect using an alias:
mariadb --defaults-group-suffix=server1