DEV Community

Funke Olasupo
Funke Olasupo

Posted on

How To Import Data From an Excel File To Your Database(MySQL) using PHPMyAdmin.

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'.
    Alt Text

  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'.
    Alt Text

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

SECTION 2

(Importing the CSV file to the database).

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

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

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

  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.
    Alt Text

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

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.🀝

Top comments (1)

Collapse
 
asaoluelijah profile image
Asaolu Elijah πŸ§™β€β™‚οΈ

Nice read πŸ’―πŸ’―