✨ Install MariaDB 11 on Ubuntu 22.04 ✨
Update System Packages
Open your terminal and run the following commands to update your system:
sudo apt update
sudo apt upgrade -y
Add the MariaDB APT Repository
Import the GPG key and add the MariaDB repository:
sudo apt install -y software-properties-common dirmngr apt-transport-https ca-certificates
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://mariadb.org/mariadb_release_signing_key.asc | sudo tee /etc/apt/keyrings/mariadb.gpg > /dev/null
Add the repository to your system:
echo "deb [signed-by=/etc/apt/keyrings/mariadb.gpg] https://mirrors.xtom.com/mariadb/repo/11.0/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/mariadb.list
Install MariaDB 11
Update your package list and install MariaDB:
sudo apt update
sudo apt install mariadb-server mariadb-client -y
Verify Installation
Check if MariaDB is running:
sudo systemctl status mariadb
If needed, start and enable MariaDB:
sudo systemctl start mariadb
sudo systemctl enable mariadb
Secure MariaDB Installation
Run the security script to configure MariaDB:
sudo mysql_secure_installation
Follow the prompts to set a root password and secure the installation.
Test MariaDB
Log in and verify the installation:
sudo mariadb -u root -p
SELECT VERSION();
EXIT;
Optional: Enable Remote Access
To allow remote connections, edit the configuration file:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Change bind-address to:
bind-address = 0.0.0.0
Restart MariaDB:
sudo systemctl restart mariadb
Backup and Restore MariaDB
Backup Process
To back up a MariaDB database, use the mysqldump command:
mysqldump -u [username] -p [database_name] > [backup_file.sql]
Example:
mysqldump -u root -p my_database > my_database_backup.sql
This will create a backup file named my_database_backup.sql in the current directory.
Restore Process
To restore a database from a backup, use the following command:
mysql -u [username] -p [database_name] < [backup_file.sql]
Example:
mysql -u root -p my_database < my_database_backup.sql
Ensure the database my_database exists before restoring, or create it with:
mysql -u root -p -e "CREATE DATABASE my_database;"
