jueves, 22 de abril de 2021

MySql: Execute SQL with command line

1) Single sql file

Using MySQL Command Line Client

if you need to execute it on a particular db, first:

use <db_name>

then:

source <full_path_of_file>

in windows you need to use '/' instead of '\'

2) Multiple sql files (in Windows)

open bash terminal navigate to the folder where the sql files are and then execute:

cat *.sql | mysql -u <user> -p <db_name>

viernes, 22 de enero de 2021

MySQL: Dump command

mysqldump --databases --user=user_name --password --host > path_to_dump_file // Dumps entire db mysqldump --user=user_name --password --host hostvalue which_db table_1 table_2 ... table_n > path_to_dump_file