MariaDB
MariaDB is a relational database.
It is free, the source code is open, and it is popular
for providing data on web servers.
Installation
The official Debian repository contains MariaDB:
apt install mariadb-server mariadb-client
To have a secure setup of the installation, execute:
mysql_secure_installation
Create Users and Databases
Open the SQL command prompt:
mysql -u root [-p]
Create a new user:
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
Create a new database:
CREATE DATABASE mydb;
Allow the new user to access the created database:
GRANT ALL PRIVILEGES ON mydb.* TO 'user'@'localhost';
FLUSH PRIVILEGES;
Backup and Restore
Dump a database to an SQL script and compress it:
mysqldump -u user -p mydb | gzip > mydb.sql.gz
Decompress and execute the SQL script to restore the database:
zcat mydb.sql.gz | mysql -u user -p mydb
PHP
To access a MariaDB database from PHP, install the connector:
apt install php-mysql
External Links
CONTENT.html | source | 2022-05-22 | 1.6 KB |