# MariaDB Database Management

ServBay offers multiple methods for effective MariaDB database management. Depending on your preference, you can opt for built-in graphical tools such as phpMyAdmin and Adminer, or take a command-line approach. Here are comprehensive steps for both approaches:

To begin, obtain the root username and password for your database.

# Get the Database Root Password

  1. Open the ServBay.

  2. Navigate to the "Settings" in the left sidebar.

Settings Tab
  1. Within the settings page, locate the "Database Password" option.
View MariaDB Password
  1. Copy the corresponding database root username and password.

# Built-in Graphical Tools

ServBay integrates phpMyAdmin and Adminer tools, providing an intuitive interface for database management. Access these tools through the following links:

# phpMyAdmin

  1. Open your browser and go to phpMyAdmin (opens new window).

  2. In "Select Server," choose the appropriate MariaDB version.

  3. Enter your MariaDB database username and the password obtained from ServBay, then click login.

  4. Within the phpMyAdmin interface, perform operations like:

    • Creating Databases:

      • Click "Databases" in the left sidebar.
      • Input the new database name, select character set and collation, then click "Create."
    • Creating Tables:

      • Within the chosen database, click the "SQL" tab.
      • Input SQL commands to create a new table, for example:
        CREATE TABLE your_table_name (
            id INT PRIMARY KEY,
            name VARCHAR(255)
        );
        
        1
        2
        3
        4
        Then click "Execute."
    • Importing Data:

      • In the chosen database, click "Import."
      • Select the SQL file to import and click "Execute."
    • Other Operations: The left sidebar allows additional actions like modifying table structure, querying data, and deleting records.

# Adminer

  1. Open your browser and go to Adminer (opens new window).

  2. Input the MariaDB database connection details (host, username, and password obtained from ServBay), then click login.

  3. Within the Adminer interface, carry out operations such as:

    • Creating Databases:

      • Click "SQL Command" in the left sidebar.
      • Input SQL commands to create a new database, for example:
        CREATE DATABASE your_database_name;
        
        1
        Then click "Execute."
    • Creating Tables:

      • Within the chosen database, click "Add Table."
      • Input the new table's name and fields, then click "Save."
    • Importing Data:

      • In the chosen database, click "Import."
      • Choose the SQL file to import and click "Import."
    • Other Operations: The left sidebar offers actions like modifying table structure, querying data, and deleting records.

Following these detailed steps, you can seamlessly manage MariaDB databases using phpMyAdmin and Adminer.

# Command-Line Management

For those preferring command-line database management, install ServBay's command-line tools. Refer to the Command-Line Support documentation for installation details.

Once the command-line tools are installed, use the following command to connect to the MariaDB database:

# Connect to the local MariaDB database
mysql -uroot -p
1
2

After connecting to the MariaDB database using ServBay's command-line tools, execute common SQL statements for database operations:

  • Creating a Database
CREATE DATABASE your_database_name;
1
  • Selecting a Database
USE your_database_name;
1
  • Creating a Table
CREATE TABLE your_table_name (
    id INT PRIMARY KEY,
    name VARCHAR(255),
    age INT
);
1
2
3
4
5
  • Inserting Data
INSERT INTO your_table_name (name, age) VALUES ('John', 25);
1
  • Querying Data
SELECT * FROM your_table_name;
1
  • Updating Data
UPDATE your_table_name SET age = 26 WHERE name = 'John';
1
  • Deleting Data
DELETE FROM your_table_name WHERE name = 'John';
1
  • Deleting a Table
DROP TABLE your_table_name;
1
  • Deleting a Database
DROP DATABASE your_database_name;
1
Last Updated: 4/24/2024