0

I got a new laptop and want to move my entire development environment, as is, to my new machine

Everything was incredibly easy, except for the MySQL database, which is turning out to be a complete nightmare. Eventually, I copied it to my new machine and got it set up, using the following:

mysqldump -u root -p tillyoudrop_dev > tillyoudrop_dev.sql

mysql -u root -p tillyoudrop_dev < tillyoudrop.sql

But when I enter the rails console, I find that only the tables seem to have copied, but no data...

For example , when I enter User I get

2.0.0-p451 :003 > User
 => User(id: integer, email: string, encrypted_password: string, reset_password_token: string, reset_password_sent_at: datetime, remember_created_at: datetime, sign_in_count: integer, current_sign_in_at: datetime, last_sign_in_at: datetime, current_sign_in_ip: string, last_sign_in_ip: string, created_at: datetime, updated_at: datetime, cart_id: integer, superadmin: boolean, invitation_token: string, invitation_sent_at: datetime, invitation_accepted_at: datetime, invitation_limit: integer, invited_by_id: integer, invited_by_type: string) 
2.0.0-p451 :004 >

which is the desired, correct behaviour, but when I look for entries:

2.0.0-p451 :004 > User.count
   (0.3ms)  SELECT COUNT(*) FROM `users` 
 => 0 
2.0.0-p451 :005 > 

There are none. How do I copy the actual data from my old dev environment to my new one?

10
  • 1
    When you look in the sql file do you actually see the data? Commented Mar 31, 2014 at 12:41
  • Yes I do. Here is an example: INSERT INTO users VALUES (5,'[email protected]','$2a$10$mz5YC.Rqp9HMf2KWWSY9QeJMrQI81lLXhMzPkkEzJS3ecsRLE9Fgy',NULL,NULL,'2013-10-17 10:22:00',44,'2013-10-29 09:23:21','2013-10-29 08:27:22','105.237.17.170','105.237.17.170','2013-07-30 14:13:57','2013-10-29 09:23:21',NULL,0,NULL,NULL,NULL,NULL,NULL,NULL),(6,'[email protected]','$2a$10$eukJZMxjRJZFcsk.ruPNHeapRZRQ082wtCgug1xeRnuKNMGYz5ScO',NULL,NULL,NULL,1,'2013-07-30 15:28:53','2013-07-30 15:28:53','196.215.97.51','196.215.97.51','2013-07-30 14:13:57','2013-07-30 15:28:53',NULL,0,NULL,NULL,NULL,NULL,NULL ... Commented Mar 31, 2014 at 12:43
  • And if you go into mysql directly, and do select count(*) from users do you see the data? Also, can you run your application on your new machine? Commented Mar 31, 2014 at 12:46
  • It seems I have two databases in here: test and information_schema. Information schema says ERROR 1109 (42S02): Unknown table 'users' in information_schema and test says ERROR 1146 (42S02): Table 'test.users' doesn't exist Commented Mar 31, 2014 at 12:57
  • I think you forgot to go into mysql and create database tillyoudrop_dev before you try to import the schema and data. Commented Mar 31, 2014 at 12:59

1 Answer 1

2

Instead of loading the data directly from the command line, import the file from within mysql itself:

$ mysql -u root -p tillyoudrop_dev

mysql> \. tillyoudrop_dev.sql

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.