Mysql import excel file into table

This topic describes how to import data from a MS Excel file.

Note

Data Import Wizard pages can slightly differ due to the product you have been using.

1. Decide what table to import the data to:

  • On the Database menu, click Import Data. The Data Import wizard opens.

    For an existing table:

  • Right-click a table in Database Explorer and select Import Data on the shortcut menu. The Data Import wizard opens with predefined parameters: a MySQL connection, a database, and a table to import the data to.
  • Alternatively, on the Database menu, click Import Data, and select a required table on the Destination table wizard page.

2. Select Excel (for Excel 97-2003) or Excel 2007 import format and specify a location of Source data. Click Next.

3. Specify a MySQL connection, a database, a schema and a table to import the data to. If you selected a table in Database Explorer before opening the Data Import wizard, the wizard will open with the predefined connection parameters of the selected table. To create or edit MySQL connections, click the corresponding buttons. Click Next.

4. Preview the Source data and specify additional options to customize the import:

  • If the source data is located on several sheets, specify which of them to choose for the import.
  • Specify the data range to import. You can see it highlighted with green in the Preview section. If you want to import the data partially, clear the Detect a range automatically check box and enter Start Cell and End Cell values or click the button next to these fields and double-click a cell in the Preview grid. The specified range will be highlighted with green, skipped lines will be highlighted with white.
  • Select to import the data either in rows or in columns.
  • Specify the header position if required. It will be highlighted with blue in the Preview section. If you don’t specify the header position, the imported columns will get default names - column1, column2, etc.

Click Next.

Mysql import excel file into table

5. Specify data formats for the Source data and click Next.

6. Map the Source columns to the Target ones. If you are importing the data into a new table, dbForge Studio will automatically create and map all the columns. If you are importing into an existing table, only columns with the same names will be mapped, the rest should be mapped manually. (If no columns with the same name are found, they are mapped in succession - the 1st column in Source with the 1st column in Target, etc.)

See the Target columns in the top and the Source columns at the bottom of the wizard page. Click Source column fields and select required columns from the drop-down list.

Note

To cancel mapping of all the columns, click Clear Mappings on the toolbar. To restore it, click Fill Mapping.

7. If you are importing to a new table, you can edit the Target column properties by double-clicking them in the top grid. Select the Key check box for a column with a primary key and click Next. Note you should select at least one column with a primary key, otherwise some of import modes on the Modes wizard page will be disabled.

8. Select the import mode to define how dbForge Studio should import the data. Click Next.

9. On the Errors handling wizard page, select how dbForge Studio should handle errors during import and whether you want to get a log file with details about the import session.

10. Click Import and see the import progress. dbForge Studio will notify you whether the import completed successfully or failed. Click the Show log file button to open the log file.

11. Click Finish to finish the import and close the wizard.

Note

You can save the import settings as a template for future uses. Click the Save Template button on any wizard page to save the selected settings. Next time you should only select a template and specify a location of the Source data - all the settings will be already set.

  • Previous
  • Next

Mysql import excel file into table

Have you ever encountered a situation where you had to import records from an Excel file to your database in MySQL?

Once, I found myself at this point, I was confused for a few minutes😢 but then I decided to consult my knowledgeable friend, Google😉.
Here I'll describe a step-by-step process to achieve this successfully.

SECTION 1

(Saving the file as a CSV document).

  1. Open the Excel file and then select 'File', a dropdown will appear and then you click 'SaveAs'.

    Mysql import excel file into table

  2. Fill in the name of the document and for the document type, Save it as (comma separated) or (comma delimited) which must have an extension of '.csv'.

    Mysql import excel file into table

  3. You will get a prompt like this, Select Yes.

    Mysql import excel file into table

SECTION 2

(Importing the CSV file to the database).

  1. Go to your PHPMyAdmin and create a new database.

    Mysql import excel file into table

  2. At the top navigation bar of your page, select Import.

    Mysql import excel file into table

  3. Select the .csv file that you saved at 'Choose File'.

    Mysql import excel file into table

  4. It is optional to fill in the table name and if you don't, the name of the file will be the table name.
    If the first line of the file contains the table column names check that box (if it is unchecked, the first line will become part of the data).
    Leave every other setting at the default unless there is a need to change it.

    Mysql import excel file into table

  5. At the bottom right corner, Select Go. Then your import is successful if your output is similar to this without any query error.

    Mysql import excel file into table

NB: If you had multiple sheets that you saved as CSV documents you import each of them repeating the above process. They will constitute the different tables in your database.

Hurray!😊 It's simple and awesome right!

Conclusion
These tips are in my own opinion, so if you have a conflicting view or a better approach, kindly drop them in the comment box, I really enjoy learning.

Thanks for reading.🤝

Can we insert data from Excel to SQL table?

First, copy the data from Excel, and then paste it into the SQL Server table using the Database > Table > Edit top 200 rows menu option. Always start by copying and pasting a single row of data to validate the data types.

How do I convert an Excel spreadsheet to a database table?

Convert Data Into a Table in Excel.
Open the Excel spreadsheet..
Use your mouse to select the cells that contain the information for the table..
Click the "Insert" tab > Locate the "Tables" group..
Click "Table". ... .
If you have column headings, check the box "My table has headers"..

Can Excel Write to MySQL database?

The Microsoft Excel spreadsheet data can be appended to a MySQL database table by using the Append Excel Data to Table option. Mapping the Excel columns to the MySQL columns can be executed automatically (default), manually, or by using a stored mapping routine.

How do I connect Excel to SQL table?

To connect Excel to a database in SQL Database, open Excel and then create a new workbook or open an existing Excel workbook. In the menu bar at the top of the page, select the Data tab, select Get Data, select From Azure, and then select From Azure SQL Database.