New answers tagged scripting
There are a couple of problems with this approach: The immediate problem is that you cannot continue an empty line. So the two lines (following each go ^ line) that are only the single character ^ are causing the line to end and not continue. It has nothing to do with the go. So you can just add a space before the carrot and it will build the full string. ...
Get rid of GO altogether. It's recognized by sqlcmd only in the interactive prompt or when reading from a file using the -i switch. If some statements need to be in a separate batch, use EXEC to wrap them. Example: EXEC('CREATE VIEW SomeView')
You could also use MySQL events (like internal cron) and select into outfile. Advantages of this method? Your backups will contain this logic. Both approaches are valid IMO just depends on your preference.
To check this out, I did the following - I created a file called my_script.sql [pol@localhost inst]$ more my_script.sql use test; select * from example; [pol@localhost inst]$ Then ran the following [pol@localhost inst]$ ./bin/mysql -S ./mysql.sock -u root -pdba < my_script.sql > xfile Warning: Using a password on the command line interface can ...
After talking to someone more knowledgeable then me I have came up with the following answers to my original questions. TLDR; Cron should be fine for what your doing but don't write a bash script, write a PHP script instead, it's better. Q1. Do I have to worry about putting the database username/password into this >cron script? A1. As long as ...
Top 50 recent answers are included