How to Use MySQL Workbench to Manage Databases
What is MySQL Workbench
MySQL Workbench is an official MySQL database design and management tool that provides an integrated development environment for database design, SQL development, database management, data migration, and more. MySQL Workbench has the following notable advantages:
- Comprehensive Features: MySQL Workbench integrates all functions of database design, development, and management.
- User-Friendly: Offers an easy-to-use graphical interface to help users execute various database operations smoothly.
- High Performance: Focuses on performance optimization, capable of quickly handling large-scale data.
- Cross-Platform Support: Supports Windows, macOS, and Linux operating systems.
For developers, MySQL Workbench not only enhances work efficiency but also simplifies the complexity of database management.
Managing the Built-in MariaDB (MySQL) Database in ServBay Using MySQL Workbench
Logging into the Server
- Download and Install MySQL Workbench: Download and install the MySQL Workbench client suitable for your operating system from the MySQL official website.
- Create a New Connection:
- Open MySQL Workbench, and click the “+” button on the home page to create a new connection.
- Enter Connection Information:
- Username and Password: Obtain these from the 'Settings' - 'Database' section of ServBay.
- Port:
3306
(Note: Only one of Port or Socket needs to be selected) - Socket:
/Applications/ServBay/tmp/mysql.sock
- Leave other information such as the database name empty to be selected later.
- Test and Save the Connection: Click the “Test Connection” button to ensure the connection information is correct, then click the “OK” button to save the connection.
Creating a Database
- Enter Database Management Interface: After a successful login, click the “Schemas” tab on the left.
- Create a New Database:
- Right-click the blank area under “Schemas” and select “Create Schema...”
- Enter the database name.
- Click the “Apply” button to create the database.
Creating a Table
- Select the Database: Expand the newly created database from the list on the left.
- Create a Table:
- Right-click “Tables” and select “Create Table...”
- Enter the table name and field information (e.g., field name, type, length, default value, etc.).
- Click the “Apply” button to create the table.
Adding Data
- Select the Table: Choose the table you want to operate on from the list on the left.
- Insert Data:
- Right-click the table name and select “Select Rows - Limit 1000”
- Click the “Apply” button in the result view to insert a new row.
- Enter the data values.
- Click the “Apply” button to save the data.
Querying Data
- Select the Table: Choose the table you want to operate on from the list on the left.
- Browse Data:
- Right-click the table name and select “Select Rows - Limit 1000”
- You can directly view the data in the table in the result view.
- You can also use the SQL query function to filter data.
Updating Data
- Select the Table: Choose the table you want to operate on from the list on the left.
- Edit Data:
- Right-click the table name and select “Select Rows - Limit 1000”
- Double-click the data row you want to modify in the result view.
- Modify the data values.
- Click the “Apply” button to save the changes.
Deleting Data
- Select the Table: Choose the table you want to operate on from the list on the left.
- Delete Data:
- Right-click the table name and select “Select Rows - Limit 1000”
- Select the data row you want to delete in the result view.
- Right-click and select “Delete Row(s)”
- Click the “Apply” button to confirm the deletion.
Deleting a Table
- Select the Database: Choose the database containing the table you want to delete from the list on the left.
- Delete the Table:
- Right-click the name of the table you want to delete and select “Drop Table...”
- Confirm the deletion operation.
Deleting a Database
- Select the Database: Choose the database you want to delete from the list on the left.
- Delete the Database;
- Right-click the database name and select “Drop Schema...”
- Confirm the deletion operation.
Following these steps, you can easily manage the built-in MariaDB (MySQL) database in ServBay using MySQL Workbench. The straightforward interface and powerful features of MySQL Workbench will greatly enhance your database management efficiency. Whether it's creating databases, tables, or inserting, querying, updating, and deleting data, MySQL Workbench provides you with a convenient operation experience.