Install and configure MariaDB (database)
Manage MySQL/MariaDB databases: creation, users, rights and optimization.
What this tutorial does
The tutorial "Install and configure MariaDB (database)" helps you achieve this goal:
Manage MySQL/MariaDB databases: creation, users, rights and optimization.
Debian/Ubuntu
-
Install MariaDB: apt install -y mariadb-server mariadb-client - Secure the installation: mysql_secure_installation
- --- Log in ---
-
mysql -u root -p - --- Database management ---
- List the bases: SHOW DATABASES;
-
Create a database: CREATE DATABASE mybase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - Delete a base: DROP DATABASE mybase;
- --- User management ---
-
Create a user: CREATE USER "myuser"@"localhost" IDENTIFIED BY "password"; -
Grant all rights: GRANT ALL PRIVILEGES ON mybase.* TO "monuser"@"localhost"; - Read-only rights: GRANT SELECT ON mybase.* TO "reader"@"localhost";
- Apply rights: FLUSH PRIVILEGES;
-
List users: SELECT user, host FROM mysql.user; - --- Import/Export ---
- Export: mysqldump -u root -p mabase > mabase.sql
-
Import: mysql -u root -p mabase < mabase.sql - --- Basic optimization ---
-
Edit /etc/mysql/mariadb.conf.d/50-server.cnf: - innodb_buffer_pool_size = 256M (adjust based on available RAM)
- query_cache_size = 64M
-
Restart: systemctl restart mariadb