Recording MySQL executions to script file in WIndows? - mysql

for my database systems assignment after we create somethings in mySQL we need to record our executions in a script file to print off to show we actually did it.
I know how to create a script file in Linux but I cannot see how to do one in Windows?

Related

can't run sql script in mysql workbench

there is problem in my mysql workbnech application , this is eror always show every i want to run sql script , anyone know about this ?
Use the free tool Opened Files View to discover which process is locking your temp files (antivirus, shell, and so on...).

Run a mysql query remotely from a PC without mysql

I am trying to automate the upload of data to a mysql database. I am using MySql Workbench on a windows pc to remotely access my database on AWS. I have a sql file that I use to load a csv file into the db using LOAD DATA LOCAL INFILE. My csv file is created daily using a scheduled task and I would like to load it into the db using a batch type file and a scheduled task.
Is it possible?
At Windows you may use PHP form Wamp Server, its very straightforward installation. You don't need MySQL Server at your local PC to update remote AWS with the data but only a scripting language.
I would suggest to install MySQL on your local PC to check firstly on that local MySQL if the update does what you expect it to do. Once it meets your expectation you just change the MySQL connection parameters to these from AWS and your set.
In MySQL Workbench you may add additional MySQL Server as local to check the local database and all applied to it changes
Perhaps this example can help link you to do first steps in writing php script to update database
PHP scripts can be executed form command line as well so once you write your script that updates the database you should be able to run it from windows CMD console this way
php -f path-to-your-sript.php
but if so you need to edit php scipt this way that it already knows where the csv file is and reads its content, maybe by this function file_get_contents() or you can also give a try a dedicated to csv files function fgetcsv() that is even more suitable because it reads line by line your CSV file so if you use loop you can even process very big CSV files without running out of the memory.

Having Trouble Writing A Small Shell Script That Creates A Dated Directory For Backup Files

I am trying to create a shell script as part of my cron job for my MySQL daily backups. I am using Webmin as the GUI interface and I was told to insert a small shell script as part of the Command to run after backup option in Webmin per noisemarine's response in this post: https://www.virtualmin.com/node/54190.
Currently, I have to manually create a folder named after the current date (e.g. 6/6/2018) and move my four MySQL database backup files into this newly created folder. If I don't, the backup files will be overwritten by the next day's backup.
All my MySQL backups are stored in /etc/mysql/MySQL Backups/. Since I am still new to this, I need help in knowing which commands/script I need to perform for the following:
Automatically create a new folder each day named after the current date
(e.g. 6/6/2018) that's stored in the /etc/mysql/MySQL Backups/ directory.
Automatically move all four .sql backup files into the newly created folder
after an automatic MySQL backup (e.g. cron job automatically backups MySQL
and subsequently, the command used in the script will automatically move the
backup files into the 6/6/2018 folder)
I tried using the following commands separated by a ; as notated by noisemarine but to no avail:
BDIR=/etc/mysql/MySQL Backups/ ; DATE=`date +%F ; mkdir -p $BDIR/$DATE ;mv $BDIR/*sql $BDIR/$DATE/
I don't know what's wrong with this picture.
Again, it looks like all I need to do is insert a list of commands in the box titled Command to run after backup option in Webmin (see attached image for visual representation).
Any help would be generously appreciated!
Thank you!
Webmin Configuration screenshot

Easiest Way to Execute a Node Script

I have an AWS-hosted MySQL database with 900+ records. I've developed a Node script that queries the database for new records, generates MP3 files for each one, uploads those files to S3 storage, and inserts the links into my database.
Right now, I'm having to execute that script manually via command prompt (npm). The script only needs to be run occasionally, so running it manually isn't a problem. But I'm sure there's an easier way than command prompt.
Is there a way to automatically run the script every so often? Or perhaps run it via a desktop shortcut? I'm open to ideas on this...just looking to simplify.
I am very new to Node and all things programming, so please forgive my ignorance here.
In Linux, you could run as a pure Linux shell script. Use a cron job to schedule the script.
Ex :
#!/usr/bin/env node
console.log('Hello world!');
In Windows, if you want to run manually, you could create a bat file and run the bat file to run the script.
Ex :
name : my_node_script.bat
node c:\path\to\file\my_node_script_code.js
If you want to run the bat file periodically, you could use Task Scheduler to schedule the bat file. See this guide of you want more details on scheduling.

Run MySql script as batch file on Windows Server

I have about 3 or so weekly generated .CSV files that are automatically placed in a particular directory on my MySQL box.
What I would like to do is run some sort of automated script that opens the MySQL command line and executes a query to delete all records in the corresponding table and LOAD DATA INFILE from the CSV's.
Being that I'm on Windows I cannot do a chronjob, though I was thinking I could do some sort of batch script and run it as a Scheduled Task.
Any idea how I would go about doing this?
Depending on your MySQL version you could use CREATE EVENT to schedule some database statements, check:
http://dev.mysql.com/doc/refman/5.1/en/create-event.html