Import donorschoose.org Data to MySQL Server
Last updated
Was this helpful?
Last updated
Was this helpful?
Whenever I write <YOUR XXX>, you should write XXX depending on your setting without "<>". For example, when I write "CD <YOUR FOLDER>", that might mean "CD C:\Program Files\MySQL\MySQL Server 8.0\bin". But that really depends on your machine. You should double check.‌
‌
First of all, you should copy data and SQL script from iSpace. There are EIGHT files:​‌
IMPORTANT: The last file is a SQL command you will use later. It should be downloaded as load_data.sql
.‌
‌
You should COPY those eight files into the folder where mysql.exe
is stored. It is "very likely" to be C:\Program Files\MySQL\MySQL Server 8.0\bin
. If so, whenever I write <YOUR FOLDER>
, that actually means C:\Program Files\MySQL\MySQL Server 8.0\bin
‌
‌
You should COPY those eight files into SOME folder you want to run MySQL from. Unlike Windows, you can run MySQL everywhere. IF you are going to run MySQL from some folder named ABC
, then copy everything into the folder ABC
. From now on, whenever I write <YOUR FOLDER>
, that actually means some folder you chose (in the earlier example, ABC
). You ALWAYS have to run MySQL from <YOUR FOLDER>
.‌
‌
‌
DO NOT use MySQL Workbench or MySQL Shell.‌
(2) Move to the folder where MySQL is installed by typing below:
‌
The folder where mysql.exe
resides is "very likely" to be "C:\Program Files\MySQL\MySQL Server 8.0\bin". In that case, you should type:
You should type this WITH quotation marks because there are spaces within the folder name (e.g. "MySQL✓Server✓8.0").‌
(3) Run MySQL by typing
‌
It will ask you a password. Type the password and enter. Don't worry even if your password doesn't show up on the screen. You are actually typing.‌
‌
(2) In terminal
, type the following:
‌
It will ask you passwords twice. First, you have to type in your MacOS password. Type that in and push enter. Then it will ask you for your MySQL password. Type that in and push enter. Don't worry even if your password doesn't show up on the screen. You are actually typing.‌
‌
‌
First, you should create a database with MySQL. This new database is a playground you will use throughout the course. You can think of a database as "a collection of tables." We will name the new database EBIS3003
.‌
In MySQL prompt, type the following:
You should run MySQL first, and then run the code above.
Never forget semicolons (;) in MySQL.‌
exit;
means you are exiting from MySQL.‌
‌
In cmd
(Windows) or terminal
(MacOS), and in <YOUR FOLDER>
, type:
‌
This should run load_data.sql
file in <YOUR FOLDER>
to create blank tables where our data will be stored.‌
‌
Find a file, C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
and open it with notepad
program. Within the file, find the line [client]
. Write local_infile=1
right below the [client]
. Like,
‌
Then, save the file, and restart your computer.‌
‌
Now you are putting the data (seven csv files you copied from iSpace) into the blank table you just created. Go back to MySQL by typing in <YOUR FOLDER>
:‌
(Windows)
‌
(MacOS)
‌
Then type the following in MySQL:
‌
This is to use our course database EBIS3003
. You have to do this every time you newly open MySQL from cmd
or terminal
.‌
Then, do this to change the setting:
‌
Next, you will read data sets with this command:
In the place of <FILENAME>, you should put the real file name. There are seven file names, donations
, projects
, schools
, teachers
, donors
, focus_areas
, focus_subjects
. Don't forget 's' at the end. Don't forget the semicolon at the end.
You SHOULD NOT push enter til the end of the command above. I broke the lines for clarity. Push enter AFTER the semicolon at the end.‌
For example,
‌
You have to do this seven times for the seven data sets (the csv files)!
If you misspecified the table names, you can delete a table by doing this (in this example, donation
table.):
DROP TABLE donations IF EXISTS;
and start over the step 6.
(1) Run Windows cmd
with an administrator authority as below:​
The command line should look like below:​‌
(1) Open terminal
:​‌
If you successfully ran MySQL the screen should look like the following:​‌