MariaDB Installation and Configuration
MariaDB Installation and Configuration
Overview
This page provides step-by-step instructions for installing MariaDB on buzz.deome.net and configuring it to work with applications like BookStack and the photo gallery.
1. Installing MariaDB
-
Update the System:
- Ensure all packages are up-to-date.
sudo apt update && sudo apt upgrade -y
- Ensure all packages are up-to-date.
-
Install MariaDB Server:
- Use the following command to install MariaDB:
sudo apt install mariadb-server -y
- Use the following command to install MariaDB:
-
Start and Enable MariaDB:
- Start the MariaDB service and enable it to start on boot:
sudo systemctl start mariadb sudo systemctl enable mariadb
- Start the MariaDB service and enable it to start on boot:
-
Verify Installation:
- Check the MariaDB version to confirm it is installed:
mysql --version - You should see output confirming the MariaDB version, as shown in your initial check.
- Check the MariaDB version to confirm it is installed:
2. Initial MariaDB Configuration
-
Run the Security Script:
- MariaDB provides a security script to help you configure common security settings.
sudo mysql_secure_installation - This script will prompt you to:
- Set a root password.
- Remove anonymous users.
- Disallow remote root login.
- Remove test databases.
- Answer each prompt as needed to secure the installation.
- MariaDB provides a security script to help you configure common security settings.
-
Log in as the Root User:
- After configuring security, log in to MariaDB:
sudo mysql -u root -p
- After configuring security, log in to MariaDB:
-
Create a New Database and User for Each Application:
-
Database for BookStack:
CREATE DATABASE bookstackdb; CREATE USER 'bookstackuser'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON bookstackdb.* TO 'bookstackuser'@'localhost'; FLUSH PRIVILEGES; -
Database for Photo Gallery:
CREATE DATABASE gallerydb; CREATE USER 'galleryuser'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON gallerydb.* TO 'galleryuser'@'localhost'; FLUSH PRIVILEGES; - Replace
your_passwordwith secure passwords.
-
Database for BookStack:
-
Exit MariaDB:
- Once databases and users are set up, exit MariaDB:
EXIT;
- Once databases and users are set up, exit MariaDB:
3. Basic MariaDB Configuration Options
-
Optimize Settings (Optional):
- Open the MariaDB configuration file:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf - Modify settings under
[mysqld]as needed. Example optimizations:max_connections = 100 innodb_buffer_pool_size = 256M - Save and close the file.
- Open the MariaDB configuration file:
-
Restart MariaDB:
- Apply changes by restarting the MariaDB service:
sudo systemctl restart mariadb
- Apply changes by restarting the MariaDB service:
4. Testing and Verification
-
Verify Databases and Users:
- Log in as root and list the databases to confirm they were created:
sudo mysql -u root -p SHOW DATABASES;
- Log in as root and list the databases to confirm they were created:
-
Connect Using Each Application’s Credentials:
- Use the created usernames and passwords to confirm access for BookStack and the gallery:
mysql -u bookstackuser -p mysql -u galleryuser -p
- Use the created usernames and passwords to confirm access for BookStack and the gallery:
-
Connection from Applications:
- Ensure that BookStack and the photo gallery application can connect to MariaDB using the specified database names and credentials.
5. Maintenance and Backup
-
Automate Backups:
- Create a cron job to back up each database:
mysqldump -u root -p bookstackdb > /path/to/backup/bookstackdb.sql mysqldump -u root -p gallerydb > /path/to/backup/gallerydb.sql
- Create a cron job to back up each database:
-
Update MariaDB:
- Periodically check for updates to keep MariaDB secure and optimized:
sudo apt update && sudo apt upgrade mariadb-server
- Periodically check for updates to keep MariaDB secure and optimized:
No Comments