To backup a MySQL database
See this link here
shell> mysqldump [arguments] > file_name
shell> mysqldump --all-databases > dump.sql
shell> mysqldump --triggers --routines --all-databases > dump.sql
shell> mysqldump --databases db1 db2 db3 > dump.sql
shell> mysqldump --databases dbname > dump.sql
OR omit the --databases
shell> mysqldump test > dump.sql
To dump only specific tables from a database use;
shell> mysqldump dbmane table1 table3 table7 > dump.sql
To dump only the structure from a database use;
shell> mysqldump --no-data dbmane > dump.sql
shell> mysqldump --d dbmane > dump.sql
Note: -d includes the triggers.
To dump only the routines from a all databases use;
mysqldump -u username -p -n -t -d -R --all-databases > routines.sql
To add the host 192.168.254.198 and the user root, do;
shell> mysqldump --host=192.168.254.198 --port=3307 -u root -p dbmane > dump.sql
See also my post here for details on how to simply copy the table structure.
mysqldump --host=[...] -udev -p --no-data --triggers --routines my_db > my_db_structure.sql
To restore a MySQL database
To login to mysql, do;
mysql -u username -p
No comments:
Post a Comment
Note: only a member of this blog may post a comment.