简体   繁体   中英

Import data to MySQL Workbench

I have a database with 6 tables, and I want to import these tables to an existing database within MySQL Workbench.

I used phpMyAdmin to export the database to a .sql file, and imported it to MySQL Workbench using "Data Import/Restore" button, but nothing happened(I don't know where this file is now in MySQL Workbench, I did get an import success message, but where exactly did this database go?). Then I tried a .CSV file, but it doesn't seem to work because it also saved the entire database, and MySQL Workbench expects only separate tables(Or not?)

Do I have to create each table separately and import data to each table individually?

Or, there is a better way to copy database content to an existing database in MySQL Workbench?

Thanks

You can use MySQL Workbench to import into an existing schema.

Server -> Data Import -> Import from self-contained file -> Default Target Schema

在此处输入图片说明

在导出 phpmyadmin 数据库时使用自定义 - 显示所有可能的选项

  1. Check whether your exported file has only data or both structure and data. If your exported file only contain data, then check the point 3
    In MySQL Workbench, we can easily export with both Structure and Data. Check the attached screenshot:

如何使用工作台导出数据库

  1. If you have already exported your database with proper format, then here's few point you need to consider before you import a file using MySQL Workbench
  • If you want to import to a new database, then you have to create a new database inside your database connection or workbench connection.
  • If you want to use an already existing database, then no need to create a new one.
  • In workbench select the database, please check attached the screenshot

如何使用工作台导入数据库

  1. If you exported database only contains data, then you have to create all the tables inside your new database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM