Terminal

Bash scripts, command line tips, etc.

Move MySQL database (export / import)

To copy a mysql database from one server to another:
# Export from the source
mysqldump -u username -p database_name >> database_name.sql
# Copy to other server
scp database_name.sql example.com:~/
# SSH to other server
ssh example.com
# Enter mysql command line
mysql -u username -p
# Create database, and import
CREATE DATABASE database_name;
USE database_name;
SOURCE /home/yourusername/database_name.sql;
exit;