Export MySQL Tables, Import MySQL Database, Add autoincrement to column through Terminal

Export Database

mysqldump -u root -p db > /path/db_backup.sql

Import Database

mysql -u root -ppassword db <  /var/www/tbl.sql

Export table

mysqldump -uroot -ppassword db tbl > /var/www/tbl.sql

Export table with WHERE clause

mysqldump --opt --user=username --password=password db tbl  --where="id>'207856'" > /var/www/tbl.sql

Import table

mysql -u root -ppassword db <  /var/www/tbl.sql

Add Autoincrement

ALTER TABLE tbl MODIFY COLUMN id INT auto_increment;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s