Excel to MySQL
-
Upload
chartio -
Category
Data & Analytics
-
view
118 -
download
0
Transcript of Excel to MySQL
![Page 1: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/1.jpg)
Excel to MySQL
![Page 2: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/2.jpg)
There may be a time when you need to create a table in MySQL and feed it with data, with this data coming from another database or combined data source.
We have created a walkthrough of importing an Excel document to MySQL - so get started today!
For the example we'll be using the an excel file on rental boats.
Excel to MySQL
![Page 3: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/3.jpg)
Open your Excel file and click Save As. Choose to save it as a .CSV (Comma Separated) file.
Note that if you are running Excel on a Mac you will need to save the file as a Windows Comma Separated (.csv) or CSV (Windows) to maintain the correct formatting.
Save as a CSV
![Page 4: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/4.jpg)
![Page 5: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/5.jpg)
Create a database
Log into your MySQL shell and create a database. For this example the database will be named boatdb. Note that the --local-infile option is needed by some versions of MySQL for the data loading we'll do in the following steps.
![Page 6: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/6.jpg)
Define the schema
Next we'll define the schema for our boat table using the CREATE TABLE command. For more details you can read the mysql documentation or take what you need from the following example.
![Page 7: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/7.jpg)
Verify your table
Run show tables to verify that your table was created
![Page 8: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/8.jpg)
Load the data
Now that there is a database and a table setup, the data can be imported with the LOAD DATA command.
![Page 9: Excel to MySQL](https://reader035.fdocuments.in/reader035/viewer/2022071813/55a2b9961a28ab3f5f8b456d/html5/thumbnails/9.jpg)
Visualize it!
If you are a Chartio user you can connect the MySQL database to Chartio and chart away.