简体   繁体   中英

MySQL Command-Line Script

These are the commands I need to execute in a script. The date 2011.02.14 needs to be a parameter:

mysql --user=myusername --password=mypassword  
connect mydatabase  
source /var/www/2011.02.14.sql  
exit

How would I execute a script to do this?

Is the "mysql --user=myusername..." part of the script, or part of the command-line for executing the rest of the script?

Thanks much.

Enclose your commands in a here doc

mysql --user=myusername --password=mypassword  << here_doc
connect mydatabase  
source /var/www/2011.02.14.sql  
exit
here_doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM