This tip would be useful for those who are either making backup of their remote mysql database or moving their web hosting to their provider.
Here’s how to export mysql DB to SQL file using command-line utility :
mysqldump –user=username –password=1234 –databases your_database –opt –quote-names –complete-insert > example.sql
or you can use this command :
$ mysql -u username -p dbname > database.sql
If the MySQL programs are not in your path, you will need to manually specify the location of the mysqldump program:
$ /usr/local/mysql/bin/mysqldump -u username -p --opt dbname > database.sql
Download the database.sql and keep it in a safe place (CDR, Zip disk, etc).
If you need to restore your database, you can do so like this:
$ mysql -u username -p databasename < database.sql
Here’s how to export mysql DB to SQL file using command-line utility :
mysqldump –user=username –password=1234 –databases your_database –opt –quote-names –complete-insert > example.sql
or you can use this command :
$ mysql -u username -p dbname > database.sql
If the MySQL programs are not in your path, you will need to manually specify the location of the mysqldump program:
$ /usr/local/mysql/bin/mysqldump -u username -p --opt dbname > database.sql
Download the database.sql and keep it in a safe place (CDR, Zip disk, etc).
If you need to restore your database, you can do so like this:
$ mysql -u username -p databasename < database.sql