Skip to content
Go back

First Database Project - Setting Up & Managing MySQL/MariaDB on Linux, Database Dump, Backup and Restore

Published:

The Assignment Tasks:

  1. Database Server Installation:

    • Install the MySQL-compatible database server (MariaDB Server) on your Linux machine.
    • Secure your MariaDB installation using the provided script.
  2. Database Creation:

    • Create a new database named broadway.
  3. User Management & Privileges:

    • Create a new database user named devops with the password 123devops.
    • Grant this devops user all necessary privileges to access databases from any host (%) or a specific remote IP address (if applicable).
  4. Table Creation & Data Insertion:

    • Within the broadway database, create a sample table (e.g., movies, artists, shows).
    • Insert several sample data records into your newly created table.
  5. External Client Connectivity:

    • Identify the default running port for your MariaDB server (e.g., 3306).
    • Configure your server’s firewall (e.g., UFW) to allow incoming connections on this database port.
    • From a separate “physical host” machine (or your local machine if the server is a VM), use telnet to verify that the database port is reachable.
    • Install a graphical database client (e.g., DBeaver, a popular open-source tool, as “db-reaver” is not a standard client) on your physical host.
    • Establish a connection to your broadway database using the devops user from this client.
    • Confirm you can view the newly created table and the inserted data through the client.
  6. Database Backup and Restore:

    • Perform a database dump (backup) of the broadway database, saving it to a file with a unique name.
    • Create a new, empty database (e.g., broadway_restored).
    • Restore the data from your backup file into this new database.
    • Verify that the broadway_restored database now contains your table and data.

output


output


Part 1: Setting up the MySQL/MariaDB Server

1. Install MariaDB Server (as mysql-server alternative)

2. Secure MariaDB Installation

This script enhances security by setting passwords, removing anonymous users, etc.

sudo mysql_secure_installation

3. Create a database broadway

4. Create a user devops with password 123devops and Grant all privileges

Important Security Note: Using simple passwords like 123devops and granting ALL PRIVILEGES ON *.* (on all databases) is generally highly discouraged in production environments. This is purely for this assignment.

5. Create a table on the database broadway


Part 2: Connecting from your “Physical Host”

Assumption for this part: Your “Linux machine” (where the MariaDB server is installed) is a VM, and your “physical host” is the machine you’re running your terminal from, which is separate from the VM. If your database server is directly on your physical machine, then “physical host” just refers to that same machine.

6. Find the database running port and ensure network reachability

7. Install db-client (assuming DBeaver)

Since db-reaver isn’t a known client, I’m assuming you meant DBeaver, which is a very popular open-source GUI database client.

8. Connect to the database using DBeaver (or your chosen client)

9. See if you can see the table

10. Insert some data into the table


Part 3: Database Dump and Restore

11. Dump the database with a unique file name

This command should be run from your Linux machine (VM) terminal.

mysqldump -u devops -p broadway > broadway_dump_$(date +%Y%m%d_%H%M%S).sql

12. Create a new database and restore the dump to the new database



Suggest Changes

Previous Post
How To Install and Configure Ansible on Ubuntu.
Next Post
Connect to Your Linux VM via SSH- Guide to Secure Remote Access and Key-Based Authentication