MySql Command line

Category: Note to Self

To import database file into a blank mysql database:

mysql -u[Username] -p [dbname] < dbname.sql

backup your db as dbname.sql in your current directory.

mysqldump [options] db_name [tables] > db_name.sql
mysqldump [options] --databases DB1 [DB2 DB3...] > db_name.sql
mysqldump [options] --all-databases > db_name.sql

If you don’t name any tables or use the –databases or –all-databases option, entire databases will be dumped.

Connecting to the database

mysql -u [username] -p [databasename]