هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
MySQL and its fork MariaDB (the default on RHEL: mariadb-server) run many web apps: WordPress, WooCommerce, ERPNext, Odoo add-ons, PHP apps. The mysql client (MariaDB also calls it mariadb) connects on port 3306 or a local socket. mysqldump (mariadb-dump) makes logical backups. mysql_secure_installation removes test users and the test database.
طريقة الكتابة
mysql [-h HOST] [-u USER] [-p] [DB] [-e "SQL"]
mysqldump [OPTIONS] DB > FILE.sqlالأجزاء الرئيسية
Useful SQL
SHOWDATABASES;/SHOWTABLES;- List.
CREATEUSER'u'@'host'IDENTIFIEDBY'pw';- New user.
GRANT…ONdb.*TO'u'@'host';- Give rights.
SHOWGRANTSFOR'u'@'host';- Show rights.
SHOWPROCESSLIST;- Running queries.
SHOWVARIABLESLIKE'x%';- Settings.
FLUSHPRIVILEGES;- Reload grants (after direct table edits).
الخيارات 8
الأكثر استخدامًا
Flags
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 10
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Install and secure MariaDB on RHEL
2Create a database and an app user
mysql -u root -p MariaDB [(none)]> CREATE DATABASE shop CHARACTER SET utf8mb4; MariaDB [(none)]> CREATE USER 'shop'@'10.20.2.%' IDENTIFIED BY 'Ch4nge-me-2026'; MariaDB [(none)]> GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO 'shop'@'10.20.2.%';3Check users and rights
mysql -u root -p -e "SELECT user, host FROM mysql.user;" mysql -u root -p -e "SHOW GRANTS FOR 'shop'@'10.20.2.%';"4Back up without locking the site
5Restore
gunzip < shop-2026-10-27.sql.gz | mysql -u root -p shop6Find slow or stuck queries
mysql -u root -p -e "SHOW FULL PROCESSLIST;" | awk '$6 > 30'7Database sizes
mysql -u root -p -e "SELECT table_schema, ROUND(SUM(data_length+index_length)/1024/1024,1) AS mb FROM information_schema.tables GROUP BY table_schema ORDER BY mb DESC;"8Keep the password out of the command line
9Listen only on the private network
10Run in a container for a lab
podman run -d --name db -e MARIADB_ROOT_PASSWORD=labonly -p 127.0.0.1:3306:3306 docker.io/library/mariadb:11.4
لا يوجد شيء يطابق هذا الفلتر.
انتبه
-pPASSWORDon the command line is visible inpsand shell history; use-por~/.my.cnf.- Never open 3306 to the internet; allow only app servers.
GRANT ALL ON *.*for an app user is a full takeover risk.
الملفات
/etc/my.cnf, /etc/my.cnf.d/- Server and client settings.
/var/lib/mysql/- Data files.
/var/log/mariadb/mariadb.log- Log (RHEL).
نصائح للحفظ
- For WordPress/WooCommerce sites, a nightly
mysqldump --single-transactionplus off-site copies is the minimum.
رموز الخروج
0 | Success. |
1 | Error (mysql) / wrong option (mysqldump). |
2 | Server error during the dump (mysqldump). |