# 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
Open the ServBay.
Navigate to the "Settings" in the left sidebar.
- Within the settings page, locate the "Database Password" option.
- 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: https://servbay.host/phpmyadmin/ (opens new window)
- Adminer: https://servbay.host/adminer.php (opens new window)
# phpMyAdmin
Open your browser and go to phpMyAdmin (opens new window).
In "Select Server," choose the appropriate MariaDB version.
Enter your MariaDB database username and the password obtained from ServBay, then click login.
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:Then click "Execute."
CREATE TABLE your_table_name ( id INT PRIMARY KEY, name VARCHAR(255) );
1
2
3
4
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
Open your browser and go to Adminer (opens new window).
Input the MariaDB database connection details (host, username, and password obtained from ServBay), then click login.
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:Then click "Execute."
CREATE DATABASE your_database_name;
1
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
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;
- Selecting a Database
USE your_database_name;
- Creating a Table
CREATE TABLE your_table_name (
id INT PRIMARY KEY,
name VARCHAR(255),
age INT
);
2
3
4
5
- Inserting Data
INSERT INTO your_table_name (name, age) VALUES ('John', 25);
- Querying Data
SELECT * FROM your_table_name;
- Updating Data
UPDATE your_table_name SET age = 26 WHERE name = 'John';
- Deleting Data
DELETE FROM your_table_name WHERE name = 'John';
- Deleting a Table
DROP TABLE your_table_name;
- Deleting a Database
DROP DATABASE your_database_name;