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:
一切都非常简单,除了MySQL数据库,这是一个完全的噩梦。最后,我把它复制到我的新机器上,并把它设置好,使用如下:
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...
但是,当我进入rails控制台时,我发现只有表看起来是复制的,但是没有数据……
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?
没有。如何将我的旧开发环境中的实际数据复制到我的新环境中?
1 个解决方案
#1
2
Instead of loading the data directly from the command line, import the file from within mysql itself:
不要直接从命令行加载数据,而是从mysql内部导入该文件:
$ mysql -u root -p tillyoudrop_dev
$ mysql -u root -p tillyoudrop_dev。
mysql> \. tillyoudrop_dev.sql
mysql > \。tillyoudrop_dev.sql
#1
2
Instead of loading the data directly from the command line, import the file from within mysql itself:
不要直接从命令行加载数据,而是从mysql内部导入该文件:
$ mysql -u root -p tillyoudrop_dev
$ mysql -u root -p tillyoudrop_dev。
mysql> \. tillyoudrop_dev.sql
mysql > \。tillyoudrop_dev.sql