In the open-source Wikibooks textbook for MySQL, the guide to insert a lot of information into a MySQL database is as follows:
Create a blank .txt file and copy/paste this information into it, saving it as tenPeople.sql.
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Mary", "Jones", 21, "female");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Jill", "Harrington", 19, "female");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Bob", "Mill", 26, "male");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Alfred", "Jinks", 23, "male");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Sandra", "Tussel", 31, "female");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Mike", "Habraha", 45, "male");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("John", "Murry", 22, "male");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Jake", "Mechowsky", 34, "male");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Hobrah", "Hinbrah", 24, "hermaphrodite");
INSERT INTO peopleInfo (firstName, lastName, age, gender) values ("Laura", "Smith", 17, "female");
Excellent. Now we want to get all these people in our table. exit MySQL and go to the directory where you saved the tenPeople.sql file. Once there, to get all the data into your database, type:
mysql -u ted -p people <tenPeople.sql and enter your password.
https://en.wikibooks.org/wiki/MySQL/MySQL_Practical_Guide
I have been trying to complete the last step, but receive the following error in Terminal:
root@debian:~# -u root -p people <~/Documents/tenPeople.sql
-bash: /root/Documents/tenPeople.sql: No such file or directory
Here, root
is my MySQL username (as opposed to "ted" in the example). I have verified that tenPeople.sql is in fact in /Users/ttoshiro/Documents/tenPeople.sql
and yet no matter what file path I put in, I keep getting an error message saying that it doesn't exist. If it matters, I am using XAMPP, and tried the following:
root@debian:~# /Applications/XAMPP/xamppfiles/bin/mysql -u root -p people < /Users/ttoshiro/Documents/tenPeople.sql
But I receive the exact same error message in this instance as well. I also tried to start MySQL directly with:
/Applications/XAMPP/xamppfiles/bin/mysql -u root -p people < /Users/ttoshiro/Documents/tenPeople.sql
In this instance, I receive an error claiming that the database 'people' is unknown: ERROR 1049 (42000): Unknown database 'people'
. This doesn't make sense because, when typing in \u people
in Terminal, I can clearly see a list of tables in the database 'people'. So, clearly the database must exist.
What am I doing wrong? Is there another way to upload .sql files containing large amounts of information using XAMPP? Why don't file paths work the same when running as root?