🗄️ Basic MySQL/MariaDB commands

Help with VPS, service, network, Linux, Nginx and WordPress problems and system administration.
rychy
Site Admin
Мнения: 132
Регистриран на: Вто Окт 20, 2026 10:45 am

🗄️ Basic MySQL/MariaDB commands

Мнение от rychy »

🇧🇬 Прочети на български

MySQL and MariaDB are the most popular databases. Here are the most important commands:

Connecting

mysql -u root -p

Databases

SHOW DATABASES; # list the databases

CREATE DATABASE my_db; # create a database

DROP DATABASE my_db; # delete a database

USE my_db; # select a database

Users

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL ON my_db.* TO 'username'@'localhost';

FLUSH PRIVILEGES;

SHOW GRANTS FOR 'username'@'localhost';

DROP USER 'username'@'localhost';

Tables

SHOW TABLES; # list the tables

DESCRIBE table_name; # table structure

Backup and restore

Backup

mysqldump -u root -p my_db > backup.sql

Restore

mysql -u root -p my_db < backup.sql

Useful commands

SHOW PROCESSLIST; # running queries

SHOW STATUS; # server status

EXIT; # exit

Any questions? Write here!