You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将MySQL Workbench的.mwb数据库架构部署至Ubuntu的MySQL服务器?

Deploy MySQL Workbench Schema (.mwb) to Ubuntu 16.04 MySQL Server

Hey there! Let's walk through getting your local MySQL Workbench schema (.mwb file) up and running on your Ubuntu 16.04 MySQL server. It's a straightforward process—here's how to do it step by step:

Step 1: Export your .mwb file to a SQL script

MySQL servers don't understand .mwb files directly, so first we need to convert it into an executable SQL script:

  • Open your .mwb file in MySQL Workbench.
  • Go to the top menu and select Database > Forward Engineer.
  • Follow the wizard prompts:
    • Confirm your local MySQL connection (if prompted).
    • Choose to include options like creating the database, table structures, indexes, and any data you want to migrate (if applicable).
    • At the final step, select "Export to Self-Contained File" and save the resulting .sql file to your local machine.

Step 2: Transfer the SQL script to your Ubuntu server

You'll need to get the .sql file onto your Ubuntu server. The easiest way is using scp from your local terminal:

scp /path/to/your/local/schema.sql your-ubuntu-username@your-server-ip:/home/your-ubuntu-username/

Replace the placeholders with your actual local file path, Ubuntu username, and server IP address. Alternatively, you can use an FTP tool like FileZilla if you prefer a GUI.

Step 3: Run the SQL script on the Ubuntu MySQL server

Now it's time to execute the script to create your schema:

  1. First, log into your Ubuntu server via SSH if you haven't already.
  2. Ensure the MySQL service is running:
    sudo systemctl status mysql
    
    If it's not running, start it with:
    sudo systemctl start mysql
    
  3. Run the SQL script. You can do this in two ways:
    • Option 1 (Interactive MySQL shell):
      mysql -u root -p
      
      Enter your MySQL root password when prompted, then run:
      -- If your SQL script doesn't include creating the database, run this first
      CREATE DATABASE your-database-name;
      USE your-database-name;
      SOURCE /home/your-ubuntu-username/schema.sql;
      
    • Option 2 (Direct shell execution):
      This skips the interactive shell—perfect for automation:
      mysql -u root -p your-database-name < /home/your-ubuntu-username/schema.sql
      
      Note: If your script creates the database automatically, you can omit your-database-name from the command.

Step 4: Verify the schema is deployed correctly

To make sure everything worked as expected:

  • Log into the MySQL shell again:
    mysql -u root -p your-database-name
    
  • Run this command to list all tables in the database:
    SHOW TABLES;
    

You should see all the tables from your .mwb schema listed here. If you included data in the export, run a quick SELECT * FROM your-table-name LIMIT 5; to confirm the data was imported correctly.

Quick Tips

  • Double-check that your MySQL user (root or another admin user) has sufficient permissions to create databases and tables.
  • If your schema includes custom functions, stored procedures, or triggers, make sure the export script included them—you can verify this by opening the .sql file in a text editor.
  • If you run into permission errors when accessing the SQL script on the server, adjust the file permissions with chmod 644 /home/your-ubuntu-username/schema.sql.

内容的提问来源于stack exchange,提问作者No110

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:25:00