Overview
The mysql/mariadb client lets you create databases, run queries and manage users
directly from a terminal — faster than a GUI once you know the basic commands. This is
essential for automation, scripting and troubleshooting on an ALYPOD Pod. This article
covers the commands you will use most often.
Before you begin
- MySQL or MariaDB installed on the Pod (see [Installing MySQL and MariaDB]).
- A database user or root access.
- For remote servers, either an SSH tunnel or a user allowed to connect from your IP.
Steps
- Connect to the server:
```bash mysql -u root -p
or on MariaDB with socket auth
sudo mysql ```
- List databases and tables:
sql
SHOW DATABASES;
USE appdb;
SHOW TABLES;
DESCRIBE users;
- Create a database and user, and grant privileges:
sql
CREATE DATABASE appdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'strong-password';
GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;
- Run a query non-interactively (useful in scripts):
bash
mysql -u appuser -p -e "SELECT COUNT(*) FROM appdb.orders;"
- Back up and restore a database with
mysqldump:
bash
mysqldump -u root -p --single-transaction appdb | gzip > appdb-$(date +%F).sql.gz
gunzip < appdb-2026-10-07.sql.gz | mysql -u root -p appdb
- Change a password and drop objects:
sql
ALTER USER 'appuser'@'localhost' IDENTIFIED BY 'new-password';
DROP TABLE old_table;
DROP DATABASE testdb;
- Exit with
exitor\q.
Troubleshooting
- Problem:
ERROR 1045 (28000): Access denied. Solution: Verify the username/host (appuser@localhostdiffers fromappuser@'%') and the password. - Problem:
ERROR 2002: Can't connect to local server. Solution: Start the service (systemctl start mariadb) and check the socket path. - Problem: Import is slow or fails on large dumps. Solution: Split the dump, or
temporarily raise
max_allowed_packetand disable foreign key checks during import.
Related articles
- [Installing MySQL and MariaDB]
- [Installing phpMyAdmin]
- [Backing up your server with rsync]
