From http://examples.oreilly.com/rubyrails/ I downloaded src-start-
chapter-4.zip and extraced the following file, which fails to import
correctly. Is this a syntax problem, a database password problem, or
what?
[email protected] ~/oreilly-photos $ [email protected] ~/oreilly-photos $ cat db/slideshow_data.sql -n | head -n
2
1 insert into slideshows values (1, ‘Interesting pictures’,
now());
2 insert into slides values (1, 1, 1, 1); [email protected] ~/oreilly-photos $ [email protected] ~/oreilly-photos $ source db/slideshow_data.sql
bash: db/slideshow_data.sql: line 1: syntax error near unexpected token (' bash: db/slideshow_data.sql: line 1:insert into slideshows values (1,
‘Interesting pictures’, now())’ [email protected] ~/oreilly-photos $ [email protected] ~/oreilly-photos $ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.0.44-log Gentoo Linux mysql-5.0.44
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> select * from oreilly_photos_development.slide_shows;
±—±-----±--------------------+
| id | name | created_at |
±—±-----±--------------------+
| 1 | foo | 2008-01-30 00:13:50 |
| 2 | bar | 2008-01-30 00:53:23 |
| 3 | baz | 2008-01-30 01:34:39 |
| 4 | blah | 2008-01-30 01:35:21 |
±—±-----±--------------------+
4 rows in set (0.50 sec)
From http://examples.oreilly.com/rubyrails/ I downloaded src-start-
chapter-4.zip and extraced the following file, which fails to import
correctly. Is this a syntax problem, a database password problem, or
what?
Just to clarify, it can be done, but not at all in the way which the
oreilly book says:
[email protected] ~/oreilly-photos $ [email protected] ~/oreilly-photos $ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.0.44-log Gentoo Linux mysql-5.0.44
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> select * from oreilly_photos_development.slide_shows;
±—±------±--------------------+
| id | name | created_at |
±—±------±--------------------+
| 1 | foo | 2008-01-30 00:13:50 |
| 2 | bar | 2008-01-30 00:53:23 |
| 3 | baz | 2008-01-30 01:34:39 |
| 4 | blah | 2008-01-30 01:35:21 |
| 5 | again | 2008-01-30 03:18:28 |
| 6 | again | 2008-01-30 03:50:31 |
±—±------±--------------------+
6 rows in set (0.00 sec)
mysql> quit;
Bye [email protected] ~/oreilly-photos $ [email protected] ~/oreilly-photos $ cat db/data.sql
insert into oreilly_photos_development.slide_shows (name,created_at)
values (“fubar”,NOW()); [email protected] ~/oreilly-photos $ [email protected] ~/oreilly-photos $ source db/data.sql
bash: db/data.sql: line 1: syntax error near unexpected token (' bash: db/data.sql: line 1: insert into
oreilly_photos_development.slide_shows (name,created_at) values
(“fubar”,NOW());’ [email protected] ~/oreilly-photos $ [email protected] ~/oreilly-photos $ mysql -u root -p < db/data.sql
Enter password: [email protected] ~/oreilly-photos $ [email protected] ~/oreilly-photos $ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 49
Server version: 5.0.44-log Gentoo Linux mysql-5.0.44
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> select * from oreilly_photos_development.slide_shows;
±—±------±--------------------+
| id | name | created_at |
±—±------±--------------------+
| 1 | foo | 2008-01-30 00:13:50 |
| 2 | bar | 2008-01-30 00:53:23 |
| 3 | baz | 2008-01-30 01:34:39 |
| 4 | blah | 2008-01-30 01:35:21 |
| 5 | again | 2008-01-30 03:18:28 |
| 6 | again | 2008-01-30 03:50:31 |
| 7 | fubar | 2008-01-30 03:54:55 |
±—±------±--------------------+
7 rows in set (0.00 sec)