如何使用.edb备份文件将MySQL数据库表恢复至重装Ubuntu系统后的新数据库?
Hey there, let's break down how to get your data from those .edb files into your fresh MySQL instance on Ubuntu. First, a quick reality check: .edb is the native database format for Microsoft Exchange Server—it’s not something MySQL can read directly. So we’ll need to go through a few steps to extract, convert, and import the data.
Step 1: Confirm What’s in Your EDB Files
First, double-check if these .edb files were actually meant to be MySQL backups. It’s possible there was a mix-up during the backup process (maybe the wrong tool was used). If you can track down a proper MySQL backup (like a .sql file from mysqldump), use that instead—it’ll save you a ton of time.
If the .edb files are your only option, they’re almost certainly from an Exchange server (or a third-party tool that exported MySQL data into this format). Let’s proceed with that assumption.
Step 2: Extract Data from the EDB File
To get usable data out of an EDB file, you’ll need a tool that can read and export its contents to a universal format like CSV or JSON:
- Microsoft’s Eseutil Tool (Windows-only): This is the official tool for working with EDB files. First, check if the file is intact:
If it’s corrupted, run a repair:eseutil /mh "C:\path\to\your\file.edb"
Once it’s healthy, you can mount it on a temporary Exchange server or use the tool to export data to CSV.eseutil /p "C:\path\to\your\file.edb" - Third-Party Recovery Tools: Tools like Stellar Repair for Exchange or SysTools Exchange Recovery make this easier—they let you browse the EDB file and export specific tables/items directly to CSV, Excel, or even PST files. These are especially helpful if you don’t have access to a Windows/Exchange environment.
If the EDB was created by a third-party MySQL backup tool, dig up that tool’s documentation to find how to reverse the process and export to SQL or CSV.
Step 3: Convert & Import to MySQL
Assuming you’ve got your data in CSV format now, let’s get it into MySQL:
- Create Matching Tables: First, recreate the table structure in your new MySQL database. Make sure the column names, data types, and constraints match your original tables exactly (you’ll need to remember or look up the original schema). Example:
CREATE TABLE customer_data ( id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) UNIQUE, signup_date DATE ); - Import the CSV: You can use the command line or a GUI tool like MySQL Workbench:
- Command Line (Ubuntu): Use
LOAD DATA INFILE(note: you may need to adjust MySQL’ssecure_file_privsetting if it restricts file imports):LOAD DATA INFILE '/home/your-user/data/customer_data.csv' INTO TABLE customer_data FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 ROWS; -- Add this if your CSV has a header row - MySQL Workbench: Go to
Server > Data Import, select your CSV file, map the columns to your table, and follow the wizard to import.
- Command Line (Ubuntu): Use
Step 4: Verify Your Data
Don’t skip this step! After importing, make sure everything looks right:
-- Check row count matches your original backup estimate SELECT COUNT(*) FROM customer_data; -- Spot-check a few rows SELECT * FROM customer_data LIMIT 10;
If you get errors about data types, adjust your table schema or clean up the CSV file (e.g., fix date formats, remove invalid characters).
内容的提问来源于stack exchange,提问作者Steph

