Reputation: 359
I have 2 servers (1 for development, 1 for service)
I keep ADD/DELETE columns and CREATE/DELETE Indexes on my development server, so these 2 server have similar but different mysql data structures.
I know there's an option to expert structures only. (like –no-data)
Is there a way (except 3rd party software like mysqldiff.org) to import structure only to an existing data?
Alternativley, is there a way to import only data ignoring non-existing tables and colums? (I thought this may do the trick if I back-up data -> import structure -> restore the data.)
thanks in advance
Upvotes: 1
Views: 2347
Reputation: 21
I had exactly the same problem. I solved it like this:
Like you already mentioned:
back-up data -> import structure -> restore the data as follows
@DEVELOPEMENT (export structure only)<br/>
**mysqldump -u user -p –d test > structure-only.sql**
@DEPLOYMENT (export data only)<br/>
**mysqldump -u user -p -t -c test > data-only.sql**
@DEPLOYMENT (import structure only)<br/>
**mysql -u user -p test < structure-only.sql**
@DEPLOYMENT (import data only)<br/>
**mysql -u user -p test < data-only.sql**
The trick that made it work for me was the -c
switch on the second export (this way full column names are used, and there are no 'column count'
errors when you import it back in the new structure).
Upvotes: 2