Skip to content

Instantly share code, notes, and snippets.

@randyjhunt
Created January 4, 2009 18:04
Show Gist options
  • Save randyjhunt/43144 to your computer and use it in GitHub Desktop.
Save randyjhunt/43144 to your computer and use it in GitHub Desktop.
exporting and importing MySQL databases
# Export database from MySQL:
sudo mysqldump -u database_username database_name > path_to_file_to_export_to.sql
# Create new database in MySQL:
CREATE DATABASE database_name;
# Grant privileges on the database:
GRANT ALL PRIVILEGES ON database_name.* TO 'db_username'@'localhost' IDENTIFIED BY 'password';
# Import the Database data:
sudo mysql -h db_server db_name < file_to_import_from.sql
# example
sudo mysql -h localhost project_dev < project_dev-2009-01-01.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment