Lesson 1 of 0
In Progress

Setting Up MariaDB

Kedeisha November 23, 2023

Step-by-Step Guide on Installing MariaDB (Compatible with MySQL)

1. Downloading MariaDB:

  • Visit the official MariaDB website and download the latest stable version of MariaDB that is compatible with your operating system (Windows, macOS, Linux).
  • Ensure that you select the appropriate package for your system (e.g., MSI package for Windows).

2. Installing MariaDB:

  • Run the installer and follow the setup wizard. The wizard will guide you through the installation process, including accepting the license agreement, choosing installation features, and setting a root password.
  • For beginners, it’s recommended to use the default settings provided by the installer.

3. Completing the Setup:

  • After installation, check the option to ‘Run MariaDB’ or open it from your applications menu.
  • You can access MariaDB using the command line interface (CLI) or a graphical user interface (GUI) like phpMyAdmin or HeidiSQL.

Creating a Basic Database and Table

1. Accessing MariaDB:

  • Open the MariaDB command line client from your applications menu. You might need to enter the root password set during installation.

2. Creating a New Database:

  • Use the command CREATE DATABASE exampleDB; to create a new database named exampleDB.

3. Selecting the Database:

  • Before creating tables, select the database with USE exampleDB;.

4. Creating a New Table:

  • Create a table using the CREATE TABLE command. For example:
CREATE TABLE customers (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100),
  email VARCHAR(100)
);

This command creates a table named ‘customers’ with three columns: ‘id’, ‘name’, and ’email’.

Basic Database Operations: CRUD

1. Creating Data (INSERT):

  • Add data to the table with the INSERT INTO command:
INSERT INTO customers (name, email) VALUES ('Alice Smith', 'alice@example.com');

2. Reading Data (SELECT):

  • Retrieve data using the SELECT command:
SELECT * FROM customers;

3. Updating Data (UPDATE):

  • Modify existing data with the UPDATE command:
UPDATE customers SET email = 'newalice@example.com' WHERE name = 'Alice Smith';

4. Deleting Data (DELETE):

  • Remove data using the DELETE FROM command:
DELETE FROM customers WHERE name = 'Alice Smith';

Conclusion

This session covers the basics of setting up MariaDB, creating a simple database and table, and performing basic CRUD (Create, Read, Update, Delete) operations. These foundational skills are crucial for anyone starting with SQL and database management. As you practice these operations, you’ll gain a deeper understanding of how databases function and how to manipulate data effectively within them.