Quickly run an SQL script from the command line without actually using the SQL interpreter.
Useful for automation of backups for instance.
mysql -u username -ppass db_name < /path/to/script.sql
Simply pipe the SQL script into mysql with <
.
-u
and -p
pass the MySQL server login creds. If -p
is present, but no password follows (note the LACK of a space between switch and the password) mysql will prompt for a password.
No Comments Yet!