Replace Mysql database from one Computer to Other

2019-07-25 05:05发布

问题:

I switched to mysql dtabase in Rails.I got a databse.sql file generated in db folder.But when i login to mysql and check data in tables then there is no records present in tables.

i used this command for dump

mysql –u root –p database_name < database_name.sql

there was no error while executing this command but when i checked the tables then there were no records in the tables.So please help me to insert all my records in database using database.sql file.There is one fiel generated database.sq.IO ned to copy this file to another pc and make all my records to insert.So how may i do this.

回答1:

You can import .sql file using the standard input like this:

mysql -u <user> -p<password> <dbname> < file.sql

Note: There shouldn't space between -p and password