Export database
USER="root" PASSWORD="password" HOST="127.0.0.1" DB_NAME="database_mame" # Export database. mysqldump --opt -u ${USER} -p${PASSWORD} -h ${HOST} ${DB_NAME} > ${DB_NAME}.sql
Note: To export tables, simply list your table names after the database name.
Import database
USER="root" PASSWORD="password" HOST="127.0.0.1" DB_NAME="database_mame" # Delete database before importing it. mysql -u ${USER} -p${PASSWORD} <<< "DROP DATABASE IF EXISTS ${DB_NAME};" mysql -u ${USER} -p${PASSWORD} <<< "CREATE DATABASE ${DB_NAME};" # Import database from *.sql file. mysql -u ${USER} -p${PASSWORD} ${DB_NAME} < ${DB_NAME}.sql &&