I want to create a bash shell script to automate MySQL by using a here-document, like this:
Will I be able to do this without messing up my database? I have valuable information in it and I don't want to lose it. I've only ever used a here-document for ed before, not for an application that doesn't operate on files.Code:mysql << EndOfScript; USE Personal_Files INSERT INTO Daily VALUES ('$year-$month-$day',NULL,NULL,NULL); EndOfScript;
Life's too short to be cool. Be a nerd.
Never mind. I just found a way to write scripts in MySQL.
Life's too short to be cool. Be a nerd.
which way do you mean?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I put the commands and queries I wanted to use in a batch file with the extension .mysql, then ran the batch file by typing sudo mysql < script.mysql in the bash terminal. I learned how to do that from the MySQL documentation at dev.mysql.com.
Life's too short to be cool. Be a nerd.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks