MySQL Execute script from CLI with Password

mysql -h "server-name" -u "root" "-pXXXXXXXX" "database-name" < "filename.sql"
Execute an SQL script from CLI with password.
Useful for automation, cron-jobs etc.

NOTE :
If you use a space after -p it makes the mysql client prompt you interactively for the password, and then it interprets the next command argument as a database-name

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.