MySQL/Snippets
From Site5Wiki
- To dump a database to a flat file after logging in via SSH, execute the following command:
mysqldump --opt -u your_database_username your_database_name -p > your_database_name.sql
You'll then be prompted for your password. This is the password for your MySQL username. Once this command completes, you'll have a .sql file containing all of your database data, ready to be backed up or imported again in to a new database!
- To restore a dump file, like the one we just generated, you would log in via SSH and execute the following command (assuming we're working with an empty database you created earlier via your control panel):
mysql -u your_database_username your_database_name -p < your_database_name.sql
When this command completes, your database will be populated with the data contained in the .sql file.
Back to MySQL
Related wiki pages: CSS, Gems, MySQL, Pear, Perl, Perl code snippets, PHP, PHP code snippets, Python, Python code snippets, Rails, Ruby, Ruby code snippets, Ruby on Rails, Smarty
