Created
January 4, 2009 18:04
-
-
Save randyjhunt/43144 to your computer and use it in GitHub Desktop.
exporting and importing MySQL databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Export database from MySQL: | |
sudo mysqldump -u database_username database_name > path_to_file_to_export_to.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create new database in MySQL: | |
CREATE DATABASE database_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Grant privileges on the database: | |
GRANT ALL PRIVILEGES ON database_name.* TO 'db_username'@'localhost' IDENTIFIED BY 'password'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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